logo资料库

Wind River Diab Compiler for PowerPC.pdf

第1页 / 共699页
第2页 / 共699页
第3页 / 共699页
第4页 / 共699页
第5页 / 共699页
第6页 / 共699页
第7页 / 共699页
第8页 / 共699页
资料共699页,剩余部分请下载后查看
Wind River Diab Compiler for PowerPC User's Guide, 5.9
Contents
Part I Introduction
1 Overview
1.1 Introduction
1.2 Overview of the Tools
Important Compiler Features and Extensions
High Performance Optimizations
Portability
1.3 Documentation
This User’s Guide
Additional Documentation
2 Configuration and Directory Structure
2.1 Introduction
2.2 Components and Directories
2.3 Accessing Current and Other Versions of the Tools
2.4 Environment Variables
2.4.1 Environment Variables Recognized by the Compiler
3 Drivers and Subprogram Flow
3.1 Introduction
3.2 Program Flow and Components
4 Selecting a Target and Its Components
4.1 Selecting a Target
VxWorks Application Development
4.2 Selected Startup Module and Libraries
4.3 Alternatives for Selecting a Target Configuration
Part II Wind River Diab Compiler
5 Invoking the Compiler
5.1 The Command Line
5.2 Rules for Writing Command-Line Options
Same Option More Than Once
Command-Line Options are Case-sensitive
Spaces In Command-Line Options
Quoting Values
Unrecognized Options, Passing Options to the Assembler or Linker
Length Limit
5.3 Examples of Processing Source Files
5.3.1 Compile and Link
5.3.2 Separate Compilation
5.3.3 Assembly Output
5.3.4 Precompiled Headers
6 Additions to ANSI C and C++
6.1 Preprocessor Predefined Macros
6.2 Preprocessor Directives
#assert and #unassert Preprocessor Directives
#error Preprocessor Directive
#ident Preprocessor Directive (C only)
#import Preprocessor Directive
#info, #inform, and #informing Preprocessor Directives
#warn and #warning Preprocessor Directives
6.3 Pragmas
align Pragma
always_inline Pragma
contract Pragma
error Pragma
flatten Pragma
global_register Pragma
hdrstop Pragma
ident Pragma
info Pragma
inline Pragma
interrupt Pragma
no_alias Pragma
noinline Pragma
no_pch Pragma
no_return Pragma
no_side_effects Pragma
option Pragma
pack Pragma
pure_function Pragma
section Pragma
use_section Pragma
warning Pragma
weak Pragma
6.4 Keywords
__asm and asm Keywords
__attribute__ Keyword
bool, pixel, vec_step, and vector AltiVec Keywords
__ev64_* Keywords
extended Keyword (C only)
__inline__ and inline Keywords
__interrupt__ and interrupt Keywords (C only)
long long Keyword
__packed__ and packed Keywords
pascal Keyword (C only)
__typeof__ Keyword (C only)
6.5 Attribute Specifiers
absolute Attribute (C only)
aligned(n) Attribute
always_inline Attribute
constructor, constructor(n) Attribute
deprecated, deprecated(string) Attribute (C only)
destructor, destructor(n) Attribute
flatten Attribute
noinline Attribute
noreturn, no_return Attribute
no_side_effects Attribute
packed Attribute
pure, pure_function Attribute
section(name) Attribute
6.6 Intrinsic Functions
6.7 Other Additions
Support for 64-bit Bit-fields
C++ Comments Permitted
Dynamic Memory Allocation with alloca
Binary Representation of Data
Assigning Global Variables to Registers
__ERROR__ Function
sizeof Extension
Statement Expressions
vararg Macros
7 Embedding Assembly Code
7.1 Introduction
7.2 asm Macros
Comments in asm Macros
Optimization
asm Statements and Special Register Names
Examples of asm Macros
7.3 asm String Statements
7.4 Reordering in asm Code
7.5 Avoiding asm Statements with Intrinsic Assembly
8 Internal Data Representation
8.1 Introduction
8.2 Basic Data Types
8.3 Byte Ordering
8.4 Arrays
8.5 Bit-fields
8.6 Classes, Structures, and Unions
8.7 C++ Classes
Pointers to Members
Virtual Function Table Generation-Key Functions
8.8 Linkage and Storage Allocation
9 Calling Conventions
9.1 Introduction
9.2 Stack Layout
EABI Stack Frame
AIX Stack Frame
9.3 Argument Passing
EABI Argument Passing
AIX Argument Passing
9.4 C++ Argument Passing
Pointer to Member as Arguments and Return Types
Member Function
Constructors and Destructors
9.5 Returning Results
Class, Struct, and Union Return Types
9.6 Register Use
10 Optimization
10.1 Introduction
10.2 Optimization Hints
What to Do From the Command Line
What to Do With Programs
10.3 Whole-Program Optimization
10.3.1 Whole-Program Optimization Usage Caveats
10.3.2 Whole-Program Optimization Examples
10.4 Target-Independent Optimizations
Various Optimizations
Tail Recursion
Inlining
Argument Address Optimization
Structure Members to Registers
Assignment Optimization
Tail Call Optimization
Common Tail Optimization
Variable Live Range Optimization
Constant and Variable Propagation
Complex Branch Optimization
Loop strength reduction
Loop Count-Down Optimization
Loop Unrolling
Global Common Subexpression Elimination
Undefined variable propagation
Unused assignment deletion
Minor Transformations to Simplify Code Generation
Register Coloring
Interprocedural Optimizations
Remove Entry and Exit Code
Use Scratch Registers for Variables
Extend Optimization
Loop Statics Optimization
Loop Invariant Code Motion
Live-Variable Analysis
Local Data Area Optimization
Feedback Optimization
10.5 Target-Dependent Optimizations
Basic Reordering (0x1)
General Peephole Optimization (0x8)
Peephole Reaching Analysis (0x20)
Merge Common Block Entry or Exit Code (0x200)
Additional Loop Optimizations (0x400)
rlwinm Peephole Optimization (0x800)
Simple Scheduling Optimization (0x1000)
Float-Move Peephole (0x4000)
Vector-Move Peephole (0x8000)
10.5.1 VLE Processors
10.6 Example of Optimizations
10.7 Suggested Optimizations
11 The Lint Facility
11.1 Introduction
11.2 Examples
12 Converting Existing Code
12.1 Introduction
12.2 Compilation Issues
Older C Code
Older Versions of the Compiler
12.3 Execution Issues
12.4 GNU Command-Line Options
13 C++ Features and Compatibility
13.1 Introduction
13.2 Header Files
13.3 C++ Standard Libraries
Nonstandard Functions
13.4 Migration From C to C++
13.5 Implementation-Specific C++ Features
Construction and Destruction of C++ Static Objects
Templates
Exceptions
Array New and Delete
Type Identification
Dynamic Casts in C++
Namespaces
Undefined Virtual Functions
Pure Virtual Function Calls
13.6 C++ Name Mangling
Demangling utility
13.7 Avoid setjmp and longjmp
13.8 Precompiled Headers
13.8.1 Reusing Precompiled Header Files
13.8.2 PCH Files
Limitations and Trade-offs
Diagnostics
14 Locating Code and Data, Addressing, Access
14.1 Controlling Access to Code and Data
14.1.1 section and use_section Pragmas
Notes for #pragma section and #pragma use_section
14.1.2 Section Classes and Their Default Attributes
Small Data Area (SDA) Sections: Including and Excluding Data
14.2 Addressing Mode - Functions, Variables, Strings
14.3 Access Mode - Read, Write, Execute
14.4 Local Data Area (-Xlocal-data-area)
14.5 Small Data and Small Const Areas
14.6 Position-Independent Code and Data (PIC and PID)
Generating Initializers for Static Variables With Position-Independent Code
Relationship Between Position-Independence and “Small” Areas
15 Use in an Embedded Environment
15.1 Introduction
15.2 Compiler Options for Embedded Development
15.3 User Modifications
15.4 Startup and Termination Code
15.4.1 Location of Startup and Termination Sources and Objects
15.4.2 Notes for crt0.s
15.4.3 Notes for crtlibso.c and ctordtor.c
15.4.4 Notes for init.c
15.4.5 Notes for Exit Functions
15.4.6 Stack Initialization and Checking
15.4.7 Dynamic Memory Allocation - the heap, malloc( ), sbrk( )
15.4.8 Run-time Initialization and Termination
15.5 Hardware Exception Handling
15.6 Library Exception Handling
15.7 Linker Command File
15.8 Operating System Calls
15.8.1 Character I/O
15.8.2 File I/O
15.8.3 Miscellaneous Functions
15.9 Communicating with the Hardware
15.9.1 Mixing C and Assembler Functions
15.9.2 Embedding Assembler Code
15.9.3 Accessing Variables and Functions at Specific Addresses
15.9.4 Shared Symbols in Multicore Systems
15.10 Reentrant and “Thread-Safe” Library Functions
15.11 Target Program Arguments, Environment Variables, and Predefined Files
15.12 Profiling in an Embedded Environment
15.13 Support for Multiple Object Formats
Part III Wind River Assembler
16 The Wind River Assembler
16.1 Introduction
16.2 Selecting the Target
16.3 The das Command
17 Syntax Rules
17.1 Format of an Assembly Language Line
Labels
Opcode
Operand Field
Comment
17.2 Symbols
17.3 Direct Assignment Statements
17.4 External Symbols
17.5 Local Symbols
Generic Style Locals
GNU-Style Locals
17.6 Constants
Integral Constants
Floating Point Constants
String Constants
18 Sections and Location Counters
18.1 Program Sections
18.2 Location Counters
19 Assembler Expressions
19.1 Introduction
19.2 Evaluation of Terms and Expressions
19.3 Unary Operators
19.3.1 High Adjust Operator
19.4 Binary Operators
19.4.1 Operator Precedence
20 Assembler Directives
20.1 Introduction
20.2 List of Directives
symbol[:] = expression
symbol[:] =: expression
.0byte
.2byte
.4byte
.align expression
.alignn expression
.ascii "string"
.asciz "string"
.balign expression
.blkb expression
.blkl
.blkw
.bss
.bsect
.byte expression ,...
.comm symbol, size [,alignment]
.data
data.l
data.w
dc.b expression
dc.l expression
dc.w expression
ds.b size
ds.l
ds.w
.double float-constant ,...
.dsect
.eject
.else
.elseif expression
.elsec
.end
.endc
.endif
.endm
.entry symbol ,...
symbol[:] .equ expression
.error "string"
.even
.exitm
.export symbol ,...
.extern symbol ,...
.file "file"
.fill count,[size[,value]]
.float float-constant ,...
.global symbol ,...
.globl symbol ,...
.half
.ident "string"
.if expression
.ifendian
.ifeq expression
.ifc "string1","string2"
.ifdef symbol
.ifge expression
.ifgt expression
.ifle expression
.iflt expression
.ifnc "string1","string2"
.ifndef symbol
.ifne expression
.import symbol ,...
.incbin "file"[,offset[,size]]
.include "file"
.lcnt expression
.lcomm symbol, size [,alignment]
.list
.llen expression
.llong expression ,...
.long expression ,...
name.macro [parameter ,...]
.mexit
.name "file"
.nolist
.org expression
.p2align expression
.page
.pagelen expression
.pcpdata
.pcptext
.plen expression
.previous
.psect
.psize page-length [,line-length]
.rdata
.rodata
.sbss [symbol, size [,alignment]]
.sbttl "string"
.sdata
.sdata2
.section name, [alignment], [type]
.section n
.sectionlink section-name
.set option
.set symbol, expression
symbol[:] .set expression
.short expression ,...
.size symbol, expression
.skip size
.space expression
.string "string"
.strz "string"
.subtitle "string"
.text
.text_vle
.title "string"
.ttl "string"
.type symbol, type
.uhalf
.ulong
.ushort
.uword
warning "string"
.weak symbol ,...
.width expression
.word expression, ...
.xdef symbol ,...
.xref symbol ,...
.xopt
21 Assembler Macros
21.1 Introduction
21.2 Macro Definition
Separating Parameter Names From Text
Generating Unique Labels
NARG Symbol
21.3 Invoking a Macro
21.4 Macros to “Define” Structures
22 Example Assembler Listing
Part IV Wind River Linker
23 The Wind River Linker
23.1 Introduction
23.2 The Linking Process
Linking Example
23.3 Symbols Created By the Linker
23.3.1 Symbols in the Linker Command File
23.4 .abs Sections
23.5 COMMON Sections
23.6 COMDAT Sections
23.7 Sorted Sections
23.8 Warning Sections
23.9 .frame_info Sections
23.10 Branch Islands
24 The dld Command
24.1 The dld Command
Linker Command Structure
24.2 Defaults
24.3 Order on the Command Line
25 Linker Command Language
25.1 Introduction
25.2 Example “bubble.dld”
25.3 Syntax Notation
25.4 Pattern Matching in Linker Command Files
25.5 Numbers
25.6 Symbols
25.7 Expressions
25.8 Command File Structure
25.9 MEMORY Command
25.10 SECTIONS Command
25.10.1 Section-Definition
Section Contents
Type Specification: ([=]BSS), ([=]COMMENT), ([=]CONST), ([=]DATA), ([=]TEXT), ([=]BTEXT); OVERLAY, NOLOAD, OPTIONAL
Address Specification
ALIGN Specification
COPYTABLE Specification
LOAD Specification
OVERFLOW Specification
SDA REGISTER Specification
Fill Specification
CRC Specification
Area Specification
STORE Statement
GROUP Definition
25.11 Cache Optimization (CACHE and PROFILE Commands)
25.12 Assignment Commands
25.13 Examples
Part V Wind River Diab Compiler Utilities
26 Utilities
26.1 Introduction
26.2 Common Command-Line Options
Show Option Summary (-?)
Read Command-Line Options from File or Variable (-@name, -@@name)
Redirect Output (-@E=file, -@E+file, -@O=file, -@O+file)
27 D-AR Archiver
27.1 Synopsis
27.2 Syntax
27.3 Description
27.3.1 dar Commands
27.4 Examples
28 D-BCNT Profiling Basic Block Counter
28.1 Synopsis
28.2 Syntax
28.3 Description
28.3.1 dbcnt Options
28.4 Files
28.4.1 Output File for Profile Data
28.5 Examples
28.6 Coverage
28.7 Notes
29 D-DUMP File Dumper
29.1 Synopsis
29.2 Syntax
29.3 Description
29.3.1 ddump commands
29.4 Examples
30 dmake Makefile Utility
30.1 Introduction
30.2 Installation
30.3 Using dmake
31 WindISS Simulator and Disassembler
31.1 Introduction
31.2 Synopsis
31.3 Simulator Mode
31.3.1 Compiling for the WindISS Simulator
31.3.2 Simulator Syntax and Options
Simulator Mode Command and Options
31.4 Batch Disassembler Mode
31.4.1 Syntax (Disassembler Mode)
31.4.2 Description
31.5 Interactive Disassembler Mode
31.5.1 Syntax (Interactive Disassembler Mode)
31.5.2 Description
31.6 Examples
Part VI C Library
32 Library Structure, Rebuilding
32.1 Introduction
32.2 Library Structure
32.2.1 Libraries Supplied
32.2.2 Library Directory Structure
32.2.3 libc.a
32.2.4 Library Search Paths
32.3 Library Sources, Rebuilding the Libraries
32.3.1 Sources
32.3.2 Rebuilding the Libraries
32.3.3 C++ Libraries
33 Header Files
33.1 Introduction
33.2 Files
33.2.1 Standard Header Files
33.3 Defined Variables, Types, and Constants
errno.h
fcntl.h
float.h
limits.h
math.h
mathf.h
setjmp.h
signal.h
stdarg.h
stddef.h
stdio.h
stdlib.h
string.h
time.h
34 C Library Functions
34.1 Format of Descriptions
34.1.1 Operating System Calls
34.1.2 Floating Point Values
34.1.3 References
34.2 Reentrant Versions
34.3 Function Listing
a64l( )
abort( )
abs( )
access( )
acos( )
acosf( )
advance( )
asctime( )
asin( )
asinf( )
assert( )
atan( )
atanf( )
atan2( )
atan2f( )
atexit( )
atof( )
atoi( )
atol( )
bsearch( )
calloc( )
ceil( )
ceilf( )
_chgsign( )
clearerr( )
clock( )
close( )
compile( )
_copysign( )
cos( )
cosf( )
cosh( )
coshf( )
creat( )
ctime( )
difftime( )
div( )
drand48( )
dup( )
ecvt( )
erf( )
erff( )
erfc( )
erfcf( )
exit( )
_exit( )
exp( )
expf( )
fabs( )
fabsf( )
fclose( )
fcntl( )
fcvt( )
fdopen( )
feof( )
ferror( )
fflush( )
fgetc( )
fgetpos( )
fgets( )
fileno( )
_finite( )
floor( )
floorf( )
fmod( )
fmodf( )
fopen( )
fprintf( )
fputc( )
fputs( )
fread( )
free( )
freopen( )
frexp( )
frexpf( )
fscanf( )
fseek( )
fsetpos( )
fstat( )
ftell( )
fwrite( )
gamma( )
gammaf( )
gcvt( )
getc( )
getchar( )
getenv( )
getopt( )
getpid( )
gets( )
getw( )
gmtime( )
hcreate( )
hdestroy( )
hsearch( )
hypot( )
hypotf( )
irand48( )
isalnum( )
isalpha( )
isascii( )
isatty( )
iscntrl( )
isdigit( )
isgraph( )
islower( )
_isnan( )
isprint( )
ispunct( )
isspace( )
isupper( )
isxdigit( )
j0( )
j0f( )
j1( )
j1f( )
jn( )
jnf( )
jrand48( )
kill( )
krand48( )
l3tol( )
l64a( )
labs( )
lcong48( )
ldexp( )
ldexpf( )
ldiv( )
_lessgreater( )
lfind( )
link( )
localeconv( )
localtime( )
log( )
_logb( )
logf( )
log10( )
log10f( )
longjmp( )
lrand48( )
lsearch( )
lseek( )
ltol3( )
mallinfo( )
malloc( )
__malloc_set_block_size( )
mallopt( )
matherr( )
matherrf( )
mblen( )
mbstowcs( )
mbtowc( )
memccpy( )
memchr( )
memcmp( )
memcpy( )
memmove( )
memset( )
mktemp( )
mktime( )
modf( )
modff( )
mrand48( )
_nextafter( )
nrand48( )
offsetof( )
open( )
perror( )
pow( )
powf( )
printf( )
putc( )
putchar( )
putenv( )
puts( )
putw( )
qsort( )
raise( )
rand( )
read( )
realloc( )
remove( )
rename( )
rewind( )
sbrk( )
_scalb( )
scanf( )
seed48( )
setbuf( )
setjmp( )
setlocale( )
setvbuf( )
signal( )
sin( )
sinf( )
sinh( )
sinhf( )
sprintf( )
sqrt( )
sqrtf( )
srand( )
srand48( )
sscanf( )
step( )
strcat( )
strchr( )
strcmp( )
strcoll( )
strcpy( )
strcspn( )
strdup( )
strerror( )
strftime( )
strlen( )
strncat( )
strncmp( )
strncpy( )
strpbrk( )
strrchr( )
strspn( )
strstr( )
strtod( )
strtok( )
strtol( )
strtoul( )
strxfrm( )
swab( )
tan( )
tanf( )
tanh( )
tanhf( )
tdelete( )
tell( )
tempnam( )
tfind( )
time( )
tmpfile( )
tmpnam( )
toascii( )
tolower( )
_tolower( )
toupper( )
_toupper( )
tsearch( )
twalk( )
tzset( )
ungetc( )
unlink( )
_unordered( )
vfprintf( )
vfscanf( )
vprintf( )
vscanf( )
vsprintf( )
vsscanf( )
wcstombs( )
wctomb( )
write( )
y0( )
y0f( )
y1( )
y1f( )
yn( )
ynf( )
Part VII Appendices
A Target Configuration
PAsemi
PowerPC
PowerPC Compressed
PowerPC VLE
B Compiler Options
B.1 Introduction
B.2 Driver Options
B.2.1 -c
B.2.2 -E
B.2.3 -P
B.2.4 -S
B.2.5 -V
B.2.6 -VV
B.2.7 -v
B.2.8 -W a, -W :as:
B.2.9 -W l, -W :ld:
B.2.10 -W m
B.2.11 -W s
B.2.12 -W x
B.2.13 -W x,arguments
B.2.14 -W x.ext
B.2.15 -Y S,dir
B.2.16 #, -##, -###
B.2.17 -@, -@@
B.2.18 -@E
B.2.19 -@O
B.3 Compiler Command-Line Options
B.3.1 -?, -??, -h, --help
B.3.2 -A-
B.3.3 -A
B.3.4 -C
B.3.5 -D
B.3.6 -e
B.3.7 -g
B.3.8 -H
B.3.9 -I
B.3.10 -I@
B.3.11 -i
B.3.12 -M
B.3.13 -O
B.3.14 -o
B.3.15 -t
B.3.16 -U
B.3.17 -W D
B.3.18 -w
B.3.19 -Y I,dir
B.4 Compiler -X Options (Overview)
Option Defaults
B.5 -X Options: Checking and Profiling
B.5.1 -Xblock-count
B.5.2 -Xfeedback
B.5.3 -Xfeedback-frequent
B.5.4 -Xfeedback-seldom
B.5.5 -Xprof-...
B.5.6 -Xprof-exec
B.5.7 -Xprof-feedback
B.5.8 -Xprof-snapshot
B.5.9 -Xrtc
B.6 -X Options: Debugging
B.6.1 -Xdebug-dwarf1
B.6.2 -Xdebug-dwarf2
B.6.3 -Xdebug-dwarf3
B.6.4 -Xdebug-dwarf2-extensions-off
B.6.5 -Xdebug-inline-on
B.6.6 -Xdebug-local-all
B.6.7 -Xdebug-local-cie
B.6.8 -Xdebug-mode
B.6.9 -Xdebug-source-line-barriers-off
B.6.10 -Xdebug-source-line-barriers-on
B.6.11 -Xdebug-struct-all
B.6.12 -Xdebug-struct-compact
B.6.13 -Xfull-pathname
B.6.14 -Xinit-locals
B.6.15 -Xinit-value
B.6.16 -Xoptimized-debug-on
B.6.17 -Xoptimized-debug-off
B.6.18 -Xstack-probe
B.7 -X Options: Diagnostic and Lint
B.7.1 -Xforce-declarations
B.7.2 -Xforce-prototypes
B.7.3 -Xlink-time-lint
B.7.4 -Xlint
B.7.5 -Xmacro-undefined-warn
B.7.6 -Xmismatch-warning
B.7.7 -Xstatic-addr-error
B.7.8 -Xstatic-addr-warning
B.7.9 -Xstderr-fully-buffered
B.7.10 -Xstop-on-warning
B.7.11 -Xstruct-arg-warning
B.7.12 -Xsuppress-warnings
B.8 -X Options: Driver
B.8.1 -Xforeign-as-ld
B.8.2 -Xgcc-options-on
B.8.3 -Xgcc-options-off
B.8.4 -Xgcc-options-verbose
B.8.5 -Xlibc
B.8.6 -Xkeep-assembly-file
B.8.7 -Xkeep-object-file
B.8.8 -Xlicense-proxy-use
B.8.9 -Xlicense-proxy-path
B.8.10 -Xlicense-wait
B.8.11 -Xpreprocess-assembly
B.8.12 -Xshow-target
B.9 -X Options: Instruction
B.9.1 -Xadd-underscore
B.9.2 -Xapu-ibm-mac
B.9.3 -Xconventions-eabi
B.9.4 -Xcrb6-always
B.9.5 -Xcrb6-float
B.9.6 -Xcrb6-never
B.9.7 -Xdebug-interrupt
B.9.8 -Xeieio
B.9.9 -Xendian-little
B.9.10 -Xinsert-nop-end
B.9.11 -Xinsert-nop-init
B.9.12 -Xintc-eoir
B.9.13 -Xinterrupt-funcs-use-rfci
B.9.14 -Xmachine-check-interrupt
B.9.15 -Xnested-interrupts
B.9.16 -Xsavefpr-avoid
B.9.17 -Xsoft-float
B.9.18 -Xspe-fpmac
B.9.19 -Xspe-int
B.9.20 -Xstmw-fast, -Xstmw-ok, -Xstmw-slow
B.9.21 -Xstrict-eabi
B.9.22 -Xstsw-fast, -Xstsw-ok, -Xstsw-slow
B.9.23 -Xtrace-table=n
B.9.24 -Xupdate-slow
B.9.25 -Xvector-...
B.9.26 -Xvrsave-...
B.10 -X Options: Memory
B.10.1 -Xalign-min
B.10.2 -Xalign-min-hardware-float
B.10.3 -Xarray-align-min
B.10.4 -Xdynamic-init
B.10.5 -Xframe-align
B.10.6 -Xglobals-volatile
B.10.7 -Xinit-section
B.10.8 -Xinit-section-default-pri
B.10.9 -Xmember-max-align
B.10.10 -Xmemory-is-volatile
B.10.11 -Xstatics-volatile
B.10.12 -Xpointers-volatile
B.10.13 -Xstring-align
B.10.14 -Xstruct-min-align
B.11 -X Options: Optimization
B.11.1 -Xalign-loop-to-cache
B.11.2 -Xargs-not-aliased
B.11.3 -Xcga-min-use
B.11.4 -Xclib-optim-off
B.11.5 -Xcode-factor
B.11.6 -Xconservative-static-live
B.11.7 -Xexplicit-inline-factor
B.11.8 -Xinline
B.11.9 -Xinline-asm-off
B.11.10 -Xinline-explicit-force
B.11.11 -Xinline-volatile-off
B.11.12 -Xint-reciprocal
B.11.13 -Xkill-opt
B.11.14 -Xkill-reorder
B.11.15 -Xlimit-reaching
B.11.16 -Xlocals-on-stack
B.11.17 -XO
B.11.18 -Xopt-count
B.11.19 -Xparse-count
B.11.20 -Xrelax-alias
B.11.21 -Xrestart
B.11.22 -Xreduce-reaching
B.11.23 -Xsize-opt
B.11.24 -Xssa
B.11.25 -Xstruct-assign-split-...
B.11.26 -Xswitch-table
B.11.27 -Xswitch-table-off
B.11.28 -Xtest-at-both
B.11.29 -Xtest-at-bottom
B.11.30 -Xtest-at-top
B.11.31 -Xunroll
B.11.32 -Xunroll-size
B.11.33 -Xwhole-program-diagnostics
B.11.34 -Xwhole-program-output-dir
B.11.35 -Xwhole-program-optim
B.12 -X Options: Output
B.12.1 -Xcpp-dump-symbols
B.12.2 -Xident-off
B.12.3 -Xincfile-missing-ignore
B.12.4 -Xmake-dependency
B.12.5 -Xmake-dependency-canonicalize-path-off
B.12.6 -Xmake-dependency-savefile
B.12.7 -Xmake-dependency-target
B.12.8 -Xpass-source
B.12.9 -Xpreprocessor-lineno-off
B.12.10 -Xsect-pri-off
B.12.11 -Xsect-pri-on
B.12.12 -Xsection-split
B.12.13 -Xshow-configuration
B.12.14 -Xunderscore-leading
B.12.15 -Xunderscore-surround
B.12.16 -Xunderscore-trailing
B.13 -X Options: Position-independence
B.13.1 -Xcode-relative...
B.13.2 -Xdata-relative...
B.13.3 -Xpic
B.14 -X Options: Sections
B.14.1 -Xaddr-code
B.14.2 -Xaddr-const
B.14.3 -Xaddr-data
B.14.4 -Xaddr-sconst
B.14.5 -Xaddr-sdata
B.14.6 -Xaddr-string
B.14.7 -Xaddr-user
B.14.8 -Xalign-functions
B.14.9 -Xbss-off, -Xbss-common-off
B.14.10 -Xbss-zero-init-const-off, -Xbss-zero-init-data-off
B.14.11 -Xcode-absolute...
B.14.12 -Xconst-in-text, -Xconst-in-data
B.14.13 -Xdata-absolute...
B.14.14 -Xdebug-align
B.14.15 -Xlocal-data-area
B.14.16 -Xlocal-data-area-static-only
B.14.17 -Xname-...
B.14.18 -Xpragma-section-...
B.14.19 -Xsection-pad
B.14.20 -Xsmall-const
B.14.21 -Xsmall-data
B.15 -X Options: Syntax
B.15.1 -Xbottom-up-init
B.15.2 -Xcpp-no-space
B.15.3 -Xc-new
B.15.4 -Xdialect-...
B.15.5 -Xdisable-keywords
B.15.6 -Xdollar-in-ident
B.15.7 -Ximport
B.15.8 -Xinline-without-body-warn
B.15.9 -Xintrinsic-mask
B.15.10 -Xkeywords
B.15.11 -Xmacro-in-pragma
B.15.12 -Xpreprocessor-old
B.15.13 -Xswap-cr-nl
B.15.14 -Xsystem-headers-warn
B.15.15 -Xtruncate
B.15.16 -Xvoid-ptr-arith-ok
B.16 -X Options: Type
B.16.1 -Xbit-fields-access-as-byte, -Xbit-fields-access-as-type
B.16.2 -Xbit-fields-compress
B.16.3 -Xbit-fields-signed, -Xbit-fields-unsigned
B.16.4 -Xchar-signed, -Xchar-unsigned
B.16.5 -Xcharset-ascii
B.16.6 -Xdouble-avoid
B.16.7 -Xdouble-error
B.16.8 -Xdouble-warning
B.16.9 -Xenum-is-...
B.16.10 -Xextend-args
B.16.11 -Xfp-fast, -Xfp-normal, -Xfp-pedantic
B.16.12 -Xold-inline-asm-casting
B.16.13 -Xfp-long-double-off, -Xfp-float-only
B.16.14 -Xfp-min-prec...
B.16.15 -Xieee754-pedantic
B.16.16 -Xstrict-bitfield-promotions
B.17 -X Options: C++
B.17.1 -Xbool-is-...
B.17.2 -Xbool-...
B.17.3 -Xc++-abr
B.17.4 -Xc++-template-name-lookup-old
B.17.5 -Xclass-type-name-visible
B.17.6 -Xcomdat-info-file
B.17.7 -Xdigraphs-...
B.17.8 -Xexceptions-...
B.17.9 -Xfor-init-scope-...
B.17.10 -Xframe-info
B.17.11 -Ximplicit-templates...
B.17.12 -Xjmpbuf-size
B.17.13 -Xmax-inst-level
B.17.14 -Xnamespace-...
B.17.15 -Xpch-...
B.17.16 -Xrtti, -Xrtti-off
B.17.17 -Xshow-inst
B.17.18 -Xstrict-ansi
B.17.19 -Xsyntax-warning-...
B.17.20 -Xusing-std-...
B.17.21 -Xwchar
B.17.22 -Xwchar_t-off
B.17.23 -Xwchar_t-on
B.18 Options By Name
B.19 Options By Numeric Code
C Assembler Options
C.1 Introduction
C.2 Assembler Command-Line Options
C.2.1 -?
C.2.2 -Dname=value
C.2.3 -g
C.2.4 -H
C.2.5 -I path
C.2.6 -l, -L
C.2.7 -o file
C.2.8 -R
C.2.9 -T ad-file
C.2.10 -ttof:environ
C.2.11 -V
C.2.12 -WDname=value
C.2.13 -WDDOBJECT=object-format
C.2.14 -WDDTARGET=target
C.2.15 -x
C.2.16 -X
C.2.17 -#
C.2.18 -@name, -@@name
C.2.19 -@E=file, -@E+file, -@O=file, -@O+file
C.3 Assembler -X Options
C.3.1 -Xalign-fill-text
C.3.2 -Xalign-value, -Xalign-power2
C.3.3 -Xapu-volatile-context
C.3.4 -Xapu-wait
C.3.5 -Xasm-debug-...
C.3.6 -Xauto-align
C.3.7 -Xcpu-...
C.3.8 -Xdebug-dwarf1
C.3.9 -Xdebug-dwarf2
C.3.10 -Xdebug-dwarf3
C.3.11 -Xdefault-align
C.3.12 -Xfix-bc-fw-mask-bug
C.3.13 -Xgnu-locals-...
C.3.14 -Xheader...
C.3.15 -Xheader-format="string"
C.3.16 -Xisa-vle
C.3.17 -Xlabel-colon...
C.3.18 -Xline-format="string"
C.3.19 -Xlist-...
C.3.20 -Xlist-file-extension="string"
C.3.21 -Xllen=n
C.3.22 -Xmacro-arg-space-...
C.3.23 -Xobject-format=form
C.3.24 -Xoptim-..
C.3.25 -Xpage-skip=n
C.3.26 -Xplen=n
C.3.27 -Xprepare-compress=n
C.3.28 -Xsemi-is-newline
C.3.29 -Xspace-...
C.3.30 -Xstrip-locals..., -Xstrip-temps...
C.3.31 -Xsubtitle="string"
C.3.32 -Xtab-size=n
C.3.33 -Xtitle="string"
C.3.34 -Xwarn-use-greg
D Linker Options
D.1 Introduction
D.2 Linker Command-Line Options
D.2.1 -?, -?X
D.2.2 -@, -@@
D.2.3 -@E=file, -@E+file, -@O=file, -@O+file
D.2.4 -A
D.2.5 -a
D.2.6 -Bd, -Bt
D.2.7 -Bsymbolic
D.2.8 -D
D.2.9 -e
D.2.10 -f
D.2.11 -L
D.2.12 -lname, -l:filename
D.2.13 -m
D.2.14 -N
D.2.15 -o file
D.2.16 -r
D.2.17 -R
D.2.18 -rpath
D.2.19 -s, -ss
D.2.20 -soname
D.2.21 -t
D.2.22 -u
D.2.23 -V
D.2.24 -VS
D.2.25 -X
D.2.26 -Y
D.3 Linker -X options
D.3.1 -Xassociate-headers
D.3.2 -Xbind-lazy
D.3.3 -Xbranch-islands
D.3.4 -Xcache-optimization
D.3.5 -Xcheck-input-patterns
D.3.6 -Xcheck-overlapping
D.3.7 -Xcombine-readonly-sections
D.3.8 -Xcode-factor-diagnostics
D.3.9 -Xcoff
D.3.10 -Xcommon-align
D.3.11 -Xcompress-debug-info
D.3.12 -Xcompress-symbols
D.3.13 -Xcopytable-section-name
D.3.14 -Xdisable-SDA
D.3.15 -Xdont-die
D.3.16 -Xdont-link
D.3.17 -Xdynamic
D.3.18 -Xelf
D.3.19 -Xelf-rela
D.3.20 -Xexclude-libs
D.3.21 -Xexclude-symbols
D.3.22 -Xexpl-instantiations
D.3.23 -Xextern-in-place
D.3.24 -Xgenerate-copytables
D.3.25 -Xgenerate-paddr
D.3.26 -Xgenerate-vmap
D.3.27 -Xignore-empty-sections
D.3.28 -Xlink-time-lint
D.3.29 -Xmax-long-branch
D.3.30 -Xmax-short-branch
D.3.31 -Xmixed-compression
D.3.32 -Xold-align
D.3.33 -Xoptimized-load
D.3.34 -Xpic-only
D.3.35 -Xprefix-underscore
D.3.36 -Xreloc-bug
D.3.37 -Xremove-unused-sections
D.3.38 -Xrescan-libraries...
D.3.39 -Xrescan-restart...
D.3.40 -Xsection-align
D.3.41 -Xshared
D.3.42 -Xsort-frame-info
D.3.43 -Xsort-section-by-alignment
D.3.44 -Xsort-section-by-name
D.3.45 -Xsort-section-by-name-desc
D.3.46 -Xstack-usage
D.3.47 -Xstatic
D.3.48 -Xstop-on-redeclaration
D.3.49 -Xstop-on-warning
D.3.50 -Xsuppress-dot
D.3.51 -Xsuppress-section-names
D.3.52 -Xsuppress-path
D.3.53 -Xsuppress-underscore
D.3.54 -Xunused-sections...
D.3.55 -Xwhole-program-jobs
E Configuration Files
E.1 Configuration Files
E.2 How Commands, Environment Variables, and Configuration Files Relate
E.2.1 Configuration Variables and Precedence
E.2.2 Startup
E.3 Standard Configuration Files
E.3.1 DENVIRON Configuration Variable
E.3.2 UFLAGS1, UFLAGS2, DFLAGS Configuration Variables
E.3.3 UAFLAGS1, UAFLAGS2, ULFLAGS1, ULFLAGS2 Configuration Variables
E.4 The Configuration Language
E.4.1 Statements and Options
E.4.2 Comments
E.4.3 String Constants
E.4.4 Variables
E.4.5 Assignment Statement
E.4.6 Error Statement
E.4.7 Exit Statement
E.4.8 If Statement
E.4.9 Include Statement
E.4.10 Print Statement
E.4.11 Switch Statement
F Compatibility Modes: ANSI, PCC, and K&R C
F.1 Introduction
F.2 Compilation Modes
F.2.1 Differences Between Compilation Modes
G Compiler Limits
G.1 Introduction
G.2 ANSI C89 Limitations
G.3 Symbol Name Limitations
G.4 Memory Limitations
G.4.1 Memory Limitations on Optimization
G.5 Debugging Limitations
H Migrating to the Wind River Diab Compiler
H.1 Introduction
H.2 Migration Issues
H.2.1 Look for Missing Standard Header Files
H.2.2 Look for Code Using Loose Typing Control
H.2.3 Look for Code Written to the K&R or PCC Standards
H.2.4 Use the GNU Options Translator
H.2.5 Older Versions of the Compiler
H.3 Execution Issues
H.3.1 Compile with -Xlint
H.3.2 Recompile Without -O
H.3.3 Look for Code Allocating Dynamic Memory In Invalid Ways
H.3.4 Look for Expressions with Undefined Order of Execution
H.3.5 Look for Code That Makes Assumptions About Implementation
I Compiler Implementation-Defined Behavior
I.1 Introduction
I.2 Translation
I.3 Environment
I.4 Library functions
J Assembler Coding Notes
J.1 Introduction
J.2 Instruction Mnemonics
J.3 Operand Addressing Modes
J.3.1 Registers
J.3.2 Expressions
K Object and Executable File Formats
K.1 Introduction
K.2 Executable and Linking Format (ELF)
K.2.1 Overall Structure
K.2.2 ELF Header
K.2.3 Program Header
ELF Program Header Fields
K.2.4 Section Headers
K.2.5 Special Sections
K.2.6 ELF Relocation Information
ELF Relocation Entry Fields
K.2.7 Line Number Information
K.2.8 Symbol Table
ELF Symbol Table Fields
K.2.9 String Table
K.3 Common Object File Format (COFF)
K.3.1 Overall Structure
COFF File Components
K.3.2 File Header
COFF Header Fields
K.3.3 Optional Header
COFF Optional (Executable) Header Fields
K.3.4 Section Headers
COFF Section Header Fields
K.3.5 Raw Data Sections
COFF section names
K.3.6 COFF Relocation Information
COFF Relocation Entry Fields
K.3.7 Line Number Information
COFF Line Number Fields
K.3.8 Symbol Table
COFF Symbol Table Felds
K.3.9 Additional Symbols
K.4 String Table
Index
Wind River Diab Compiler for PowerPC User's Guide, 5.9 ® Wind River Diab Compiler for PowerPC USER'S GUIDE 5.9 Edition 2
Copyright © 2011 Wind River Systems, Inc. All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means without the prior written permission of Wind River Systems, Inc. Wind River, Tornado, and VxWorks are registered trademarks of Wind River Systems, Inc. The Wind River logo is a trademark of Wind River Systems, Inc. Any third-party trademarks referenced are the property of their respective owners. For further information regarding Wind River trademarks, please see: www.windriver.com/company/terms/trademark.html This product may include software licensed to Wind River by third parties. Relevant notices (if any) are provided in your product installation at one of the following locations: installDir/product_name/3rd_party_licensor_notice.pdf installDir/legal-notices/ Wind River may refer to third-party documentation by listing publications or providing links to third-party Web sites for informational purposes. Wind River accepts no responsibility for the information provided in such third-party documentation. Corporate Headquarters Wind River 500 Wind River Way Alameda, CA 94501-1153 U.S.A. Toll free (U.S.A.): 800-545-WIND Telephone: Facsimile: 510-748-4100 510-749-2010 For additional contact information, see the Wind River Web site: www.windriver.com For information on how to contact Customer Support, see: www.windriver.com/support Wind River Diab Compiler for PowerPC User's Guide 5.9 Edition 2 31 Oct 11
Contents PART I: INTRODUCTION 1 Overview ...................................................................................................... 1.1 1.2 1.3 Introduction ...................................................................................................................... Overview of the Tools .................................................................................................... Documentation ................................................................................................................ 2 Configuration and Directory Structure ..................................................... 2.1 2.2 2.3 2.4 Introduction ...................................................................................................................... Components and Directories ........................................................................................ Accessing Current and Other Versions of the Tools ................................................ Environment Variables .................................................................................................. 3 3 3 6 9 9 9 13 14 3 Drivers and Subprogram Flow .................................................................. 17 3.1 3.2 Introduction ...................................................................................................................... Program Flow and Components ................................................................................... 17 17 4 Selecting a Target and Its Components ................................................... 21 4.1 4.2 4.3 Selecting a Target ............................................................................................................ Selected Startup Module and Libraries ...................................................................... Alternatives for Selecting a Target Configuration ................................................... 21 23 24 iii
Wind River Diab Compiler for PowerPC User's Guide, 5.9 PART II: WIND RIVER DIAB COMPILER 5 Invoking the Compiler ................................................................................ 27 5.1 5.2 5.3 The Command Line ........................................................................................................ Rules for Writing Command-Line Options ............................................................... Examples of Processing Source Files ........................................................................... 27 28 30 6 Additions to ANSI C and C++ .................................................................... 33 6.1 6.2 6.3 6.4 6.5 6.6 6.7 Preprocessor Predefined Macros .................................................................................. Preprocessor Directives .................................................................................................. Pragmas ............................................................................................................................. Keywords .......................................................................................................................... Attribute Specifiers ......................................................................................................... Intrinsic Functions .......................................................................................................... Other Additions ............................................................................................................... 33 35 38 48 51 56 58 7 Embedding Assembly Code ...................................................................... 63 7.1 7.2 7.3 7.4 7.5 Introduction ...................................................................................................................... asm Macros ....................................................................................................................... asm String Statements .................................................................................................... Reordering in asm Code ................................................................................................ Avoiding asm Statements with Intrinsic Assembly ................................................. 63 64 70 71 72 8 Internal Data Representation ..................................................................... 73 8.1 8.2 8.3 8.4 8.5 8.6 8.7 Introduction ...................................................................................................................... Basic Data Types ............................................................................................................. Byte Ordering ................................................................................................................... Arrays ................................................................................................................................ Bit-fields ............................................................................................................................ Classes, Structures, and Unions ................................................................................... C++ Classes ....................................................................................................................... 73 73 75 75 75 77 77 iv
Contents 8.8 Linkage and Storage Allocation ................................................................................... 80 9 Calling Conventions ................................................................................... 83 9.1 9.2 9.3 9.4 9.5 9.6 Introduction ...................................................................................................................... Stack Layout ..................................................................................................................... Argument Passing .......................................................................................................... C++ Argument Passing .................................................................................................. Returning Results ........................................................................................................... Register Use ...................................................................................................................... 83 83 86 88 90 90 10 Optimization ................................................................................................ 93 10.1 Introduction ...................................................................................................................... 10.2 Optimization Hints ......................................................................................................... 10.3 Whole-Program Optimization ...................................................................................... 93 93 98 10.4 Target-Independent Optimizations ............................................................................. 100 10.5 Target-Dependent Optimizations ................................................................................ 111 10.6 Example of Optimizations ............................................................................................. 114 10.7 Suggested Optimizations .............................................................................................. 117 11 The Lint Facility .......................................................................................... 119 11.1 Introduction ...................................................................................................................... 119 11.2 Examples ........................................................................................................................... 120 12 Converting Existing Code .......................................................................... 123 12.1 Introduction ...................................................................................................................... 123 12.2 Compilation Issues ......................................................................................................... 123 12.3 Execution Issues .............................................................................................................. 125 12.4 GNU Command-Line Options ..................................................................................... 126 13 C++ Features and Compatibility ................................................................ 127 13.1 Introduction ...................................................................................................................... 127 v
Wind River Diab Compiler for PowerPC User's Guide, 5.9 13.2 Header Files ...................................................................................................................... 127 13.3 C++ Standard Libraries .................................................................................................. 128 13.4 Migration From C to C++ ............................................................................................... 129 13.5 Implementation-Specific C++ Features ...................................................................... 130 13.6 C++ Name Mangling ...................................................................................................... 133 13.7 Avoid setjmp and longjmp ............................................................................................ 134 13.8 Precompiled Headers ...................................................................................................... 134 14 Locating Code and Data, Addressing, Access ........................................ 137 14.1 Controlling Access to Code and Data .......................................................................... 137 14.2 Addressing Mode - Functions, Variables, Strings .................................................... 143 14.3 Access Mode — Read, Write, Execute ......................................................................... 145 14.4 Local Data Area (-Xlocal-data-area) ............................................................................. 150 14.5 Small Data and Small Const Areas .............................................................................. 151 14.6 Position-Independent Code and Data (PIC and PID) .............................................. 152 15 Use in an Embedded Environment ........................................................... 155 15.1 Introduction ...................................................................................................................... 155 15.2 Compiler Options for Embedded Development ....................................................... 156 15.3 User Modifications .......................................................................................................... 157 15.4 Startup and Termination Code ..................................................................................... 157 15.5 Hardware Exception Handling ..................................................................................... 163 15.6 Library Exception Handling .......................................................................................... 163 15.7 Linker Command File ..................................................................................................... 164 15.8 Operating System Calls ................................................................................................. 165 15.9 Communicating with the Hardware ............................................................................ 168 15.10 Reentrant and “Thread-Safe” Library Functions ...................................................... 169 15.11 Target Program Arguments, Environment Variables, and Predefined Files ....... 170 15.12 Profiling in an Embedded Environment .................................................................... 172 vi
Contents 15.13 Support for Multiple Object Formats ......................................................................... 173 PART III: WIND RIVER ASSEMBLER 16 The Wind River Assembler ........................................................................ 177 16.1 Introduction ...................................................................................................................... 177 16.2 Selecting the Target ........................................................................................................ 177 16.3 The das Command .......................................................................................................... 178 17 Syntax Rules ............................................................................................... 179 17.1 Format of an Assembly Language Line ...................................................................... 179 17.2 Symbols ............................................................................................................................. 181 17.3 Direct Assignment Statements ..................................................................................... 182 17.4 External Symbols ............................................................................................................. 182 17.5 Local Symbols .................................................................................................................. 183 17.6 Constants ........................................................................................................................... 184 18 Sections and Location Counters ............................................................... 187 18.1 Program Sections ............................................................................................................. 187 18.2 Location Counters ........................................................................................................... 188 19 Assembler Expressions ............................................................................. 191 19.1 Introduction ...................................................................................................................... 191 19.2 Evaluation of Terms and Expressions ......................................................................... 191 19.3 Unary Operators .............................................................................................................. 192 19.4 Binary Operators ............................................................................................................. 194 20 Assembler Directives ................................................................................. 197 20.1 Introduction ...................................................................................................................... 197 20.2 List of Directives ............................................................................................................. 198 21 Assembler Macros ...................................................................................... 217 21.1 Introduction ...................................................................................................................... 217 vii
Wind River Diab Compiler for PowerPC User's Guide, 5.9 21.2 Macro Definition ............................................................................................................. 217 21.3 Invoking a Macro ............................................................................................................ 220 21.4 Macros to “Define” Structures ...................................................................................... 220 22 Example Assembler Listing ....................................................................... 223 PART IV: WIND RIVER LINKER 23 The Wind River Linker ................................................................................ 227 23.1 Introduction ...................................................................................................................... 227 23.2 The Linking Process ....................................................................................................... 228 23.3 Symbols Created By the Linker .................................................................................... 231 23.4 .abs Sections ..................................................................................................................... 233 23.5 COMMON Sections ........................................................................................................ 233 23.6 COMDAT Sections ......................................................................................................... 234 23.7 Sorted Sections ................................................................................................................ 235 23.8 Warning Sections ............................................................................................................ 235 23.9 .frame_info Sections ....................................................................................................... 236 23.10 Branch Islands .................................................................................................................. 236 24 The dld Command ...................................................................................... 239 24.1 The dld Command .......................................................................................................... 239 24.2 Defaults ............................................................................................................................. 241 24.3 Order on the Command Line ........................................................................................ 241 25 Linker Command Language ...................................................................... 243 25.1 Introduction ...................................................................................................................... 243 25.2 Example “bubble.dld” .................................................................................................... 244 25.3 Syntax Notation ............................................................................................................... 245 25.4 Pattern Matching in Linker Command Files ............................................................. 246 25.5 Numbers ............................................................................................................................ 246 viii
分享到:
收藏