Contents


 Introduction to Diab C/C++    1

1 Overview 3
1.1 Professional programming tools 4
1.1.1 Flexible 4
1.1.2 Important compiler features and extensions 4
1.1.3 High performance optimizations 5
1.1.4 Portability 6
1.2 Documentation 7
1.2.1 This User's Guide 7
1.2.2 Additional documentation 8
1.3 Document conventions 9

2 Installing the Compiler Suites 11
2.1 Installation and components 11
2.2 Accessing current and other versions of the tools 17
2.3 Environment variables 18

3 Drivers and Subprogram Flow 21

4 Selecting a Target and Its Components 25
4.1 Selecting a target 25
4.2 Selected startup module and libraries 30
4.3 Alternatives for selecting a target configuration 31

 Diab C/C++ Compilers    33

5 Invoking the Compiler 35
5.1 The command line 35
5.2 Rules for writing command line options 36
5.3 Compiler command line options 39
5.3.1 Show information about compiler options (-?, -??, -?W, -?X) 39
5.3.2 Ignore predefined macros and assertions (-A-) 40
5.3.3 Define assertion (-A assertion) 40
5.3.4 Pass along comments (-C) 40
5.3.5 Stop after assembly, produce object (-c) 40
5.3.6 Define preprocessor macro name (-D name=definition) 41
5.3.7 Stop after preprocessor, write source to standard output (-E) 41
5.3.8 Change diagnostic severity level (-e) 41
5.3.9 Generate symbolic debugger information (-g) 42
5.3.10 Print path names of header files (-H) 43
5.3.11 Specify directory for header files (-I dir) 44
5.3.12 Control search for user-defined header files (-I@) 45
5.3.13 Modify header file processing (-i file1=file2) 45
5.3.14 Specify directory for -l search list (-L dir) 45
5.3.15 Specify library or process file (-l name) 45
5.3.16 Specify pathname of target-spec file (-M target-spec) 45
5.3.17 Optimize code (-O) 46
5.3.18 Specify output file (-o file) 46
5.3.19 Stop after preprocessor, produce source (-P) 47
5.3.20 Stop after compilation, produce assembly (-S) 47
5.3.21 Select the target processor (-t tof:environ) 47
5.3.22 Undefine preprocessor macro name (-U name) 47
5.3.23 Display current version number (-V, -VV) 48
5.3.24 Run driver in verbose mode (-v) 48
5.3.25 Pass arguments to the assembler (-W a,arguments, -W :as:,arguments) 48
5.3.26 Define configuration variable (-W Dname=value) 48
5.3.27 Pass arguments to the linker (-W l,arguments, -W :ld:,arguments) 49
5.3.28 Specify linker command file (-W mfile) 49
5.3.29 Specify startup module (-W sfile) 49
5.3.30 Substitute program or file for default (-W xfile) 50
5.3.31 Pass arguments to subprogram (-W x,arguments) 51
5.3.32 Associate source file extension (-W x.ext) 52
5.3.33 Suppress all compiler warnings (-w) 52
5.3.34 Set options providing detailed control of the compiler (-X option) 53
5.3.35 Specify default header file search path (-Y I,dir) 53
5.3.36 Specify search directories for -l (-Y L, -Y P, -Y U) 53
5.3.37 Print subprograms with arguments (-#, -##, -###) 53
5.3.38 Read command line options from file or variable (-@name, -@@name) 53
5.3.39 Redirect output (-@E=file, -@E+file, -@O=file, -@O+file) 54
5.4 Compiler -X options 54
5.4.1 Option defaults 54
5.4.2 Compiler -X options by function 55
5.4.3 Prefix function identifiers with underscore (-Xadd-underscore) 61
5.4.4 Set addressing mode for sections (-Xaddr-...) 61
5.4.5 Align functions on n-byte boundaries (-Xalign-functions=n) 62
5.4.6 Specify minimum alignment for single memory access to multi-byte values (-Xalign-min=n) 62
5.4.7 Specify minimum alignment for memory access to float registers (-Xalign-min-hardware-float) 63
5.4.8 Assume no aliasing of pointer arguments (-Xargs-not-aliased) 63
5.4.9 Specify minimum array alignment (-Xarray-align-min) 64
5.4.10 Disable bit-field access optimization (-Xbit-fields-access-as-byte, -Xbit-fields-access-as-type) 64
5.4.11 Change bit-field type to reduce structure size (-Xbit-fields-compress-...) 65
5.4.12 Specify sign of plain bit-field (-Xbit-fields-signed, -Xbit-fields-unsigned) 65
5.4.13 Insert profiling code (-Xblock-count) 66
5.4.14 Set type for bool (-Xbool-is-...) 66
5.4.15 Control use of bool, true, and false keywords (-Xbool-...) 66
5.4.16 Parse initial values bottom-up (-Xbottom-up-init) 66
5.4.17 Control allocation of uninitialized variables in "COMMON" and .bss sections (-Xbss-off, -Xbss-common-off) 67
5.4.18 Use old C++ compiler (-Xc++-old) 67
5.4.19 Generate code using ASCII character set (-Xcharset-ascii) 68
5.4.20 Specify sign of plain char (-Xchar-signed, -Xchar-unsigned) 68
5.4.21 Use old for scope rules (-Xclass-type-name-visible) 68
5.4.22 Disregard ANSI C library functions (-Xclib-optim-off) 69
5.4.23 Use absolute addressing for code (-Xcode-absolute...) 69
5.4.24 Generate position-independent code (PIC) (-Xcode-relative...) 70
5.4.25 Mark sections as COMDAT for linker collapse (-Xcomdat) 71
5.4.26 Optimize static and global variable access conservatively (-Xconservative-static-live) 71
5.4.27 Select EABI calling conventions (-Xconventions-eabi) 72
5.4.28 Locate constants with "text" or "data" (-Xconst-in-text, -Xconst-in-data) 72
5.4.29 Dump symbol information for macros or assertions (-Xcpp-dump-symbols) 72
5.4.30 Suppress preprocessor spacing (-Xcpp-no-space) 73
5.4.31 Specify CR bit 6 for an unprototyped function call using (-Xcrb6-always, -Xcrb6-float, -Xcrb6-never) 73
5.4.32 Use absolute addressing for code (-Xdata-absolute...) 73
5.4.33 Generate position-independent data (PID) (-Xdata-relative...) 74
5.4.34 Align .debug sections (-Xdebug-align=n) 74
5.4.35 Select DWARF format (-Xdebug-dwarf...) 75
5.4.36 Disable extensions to debugging information (-Xdebug-mode=mask) 75
5.4.37 Disable debug information optimization (-Xdebug-struct-...) 75
5.4.38 Specify C dialect (-Xdialect-ansi, -Xdialect-k-and-r, -Xdialect-pcc, -Xdialect-strict-ansi) 76
5.4.39 Disable digraphs (-Xdigraphs-...) 76
5.4.40 Allow dollar signs in identifiers (-Xdollar-in-ident) 76
5.4.41 Control use of type "double" (-Xdouble...) - C only 77
5.4.42 Generate initializers for static variables (-Xdynamic-init) 77
5.4.43 Prevent reordering of memory access (-Xeieio) 77
5.4.44 Specify enum type (-Xenum-is-...) 78
5.4.45 Compile in little-endian mode (-Xendian-little) 79
5.4.46 Enable exceptions (-Xexceptions-...) 79
5.4.47 Control inlining expansion (-Xexplicit-inline-factor) 79
5.4.48 Force precision of real arguments (-Xextend-args) 80
5.4.49 Optimize using profile data (-Xfeedback=file) 80
5.4.50 Set optimization parameters used with profile data (-Xfeedback-frequent, -Xfeedback-seldom) 81
5.4.51 Use old for scope rules (-Xfor-init-scope-...) 82
5.4.52 Generate warnings on undeclared functions (-Xforce-declarations, -Xforce-prototypes) 82
5.4.53 Suppress assembler and linker parameters (-Xforeign-as-ld) 82
5.4.54 Convert double and long double (-Xfp-long-double-off, -Xfp-float-only) 83
5.4.55 Specify minimum floating point precision (-Xfp-min-prec...) 83
5.4.56 Include path to file name in debug information (-Xfull-pathname) 84
5.4.57 Do not pass #ident strings (-Xident-off) 84
5.4.58 Enable strict implementation of IEEE754 floating point standard (-Xieee754-pedantic) 84
5.4.59 Control template instantiation (-Ximplicit-templates...) 84
5.4.60 Treat #include as #import (-Ximport) 85
5.4.61 Ignore missing include files (-Xincfile-missing-ignore) 85
5.4.62 Initialize local variables (-Xinit-locals=mask) 86
5.4.63 Create .init section (-Xinit-section) 86
5.4.64 Define initial value for -Xinit-locals (-Xinit-value=n) 86
5.4.65 Inline functions with fewer than n nodes (-Xinline=n) 87
5.4.66 Allow inlining of recursive function calls (-Xinline-explicit-force) 87
5.4.67 Insert nops into end of functions(-Xinsert-nop-end) 87
5.4.68 Insert nops into beginning of functions(-Xinsert-nop-init) 88
5.4.69 Return from interrupt function using rfci (-Xinterrupt-funcs-use-rfci) 88
5.4.70 Enable intrinsic functions (-Xintrinsic-mask) 88
5.4.71 Set longjmp buffer size (-Xjmpbuf-size=n) 88
5.4.72 Create and keep assembly or object file (-Xkeep-assembly-file, -Xkeep-object-file) 88
5.4.73 Enable extended keywords (-Xkeywords=mask) 89
5.4.74 Disable individual optimizations (-Xkill-opt=mask, -Xkill-reorder=mask) 89
5.4.75 Wait for license (-Xlicense-wait) 90
5.4.76 Generate warnings on suspicious/non-portable code (-Xlint=mask) 91
5.4.77 Do not assign locals to registers (-Xlocals-on-stack) 92
5.4.78 Allocate static and global variables to local data area (-Xlocal-data-area=n) 92
5.4.79 Expand macros in pragmas (-Xmacro-in-pragma) 93
5.4.80 Warn on undefined macro in #if statement (-Xmacro-undefined-warn) 93
5.4.81 Show make rules (-Xmake-dependency) 93
5.4.82 Set template instantiation recursion limit (-Xmax-inst-level=n) 94
5.4.83 Set maximum structure member alignment (-Xmember-max-align=n) 94
5.4.84 Treat all variables as volatile (-Xmemory-is-volatile) 95
5.4.85 Warn on pointer type mismatch (-Xmismatch-warning) 95
5.4.86 Specify section name (-Xname-...) 95
5.4.87 Disable C++ keywords namespace and using (-Xnamespace-...) 96
5.4.88 Save registers for nested interrupts (-Xnested-interrupts) 96
5.4.89 Enable extra optimizations (-XO) 97
5.4.90 Execute the compiler's optimizing stage n times (-Xopt-count=n) 97
5.4.91 Disable most optimizations with -g (-Xoptimized-debug-...) 97
5.4.92 Specify optimization buffer size (-Xparse-size) 98
5.4.93 Output source as comments (-Xpass-source) 98
5.4.94 Use precompiled headers (-Xpch-...) 98
5.4.95 Control interpretation of multiple section pragmas (-Xpragma-section-...) 99
5.4.96 Preprocess assembly files (-Xpreprocess-assembly) 99
5.4.97 Suppress line numbers in preprocessor output (-Xpreprocessor-lineno-off) 99
5.4.98 Use old preprocessor (-Xpreprocessor-old) 99
5.4.99 Generate profiling code for the RTA Run-Time Analysis Tool Suite (-Xprof-...) 100
5.4.100 Select target executable for use by -Xprof-feedback (-Xprof-exec) 101
5.4.101 Optimize using RTA profile data (-Xprof-feedback) 101
5.4.102 Select snapshot for use by -Xprof-feedback (-Xprof-snapshot) 102
5.4.103 Restart optimization from scratch (-Xrestart) 103
5.4.104 Generate code for the Run-Time Error Checker (-Xrtc=mask) 103
5.4.105 Enable run-time type information (-Xrtti, -Xrtti-off) 104
5.4.106 Pad sections for optimized loading (-Xsection-pad) 104
5.4.107 Generate each function in a separate CODE section class (-Xsection-split) 105
5.4.108 Disable generation of priority section names (-Xsect-pri-...) 105
5.4.109 Show target (-Xshow-target) 105
5.4.110 Optimize for size rather than speed (-Xsize-opt) 106
5.4.111 Set size limit for "small const" variables (-Xsmall-const=n) 106
5.4.112 Set size limit for "small data" variables (-Xsmall-data=n) 106
5.4.113 Select software floating point emulation (-Xsoft-float) 106
5.4.114 Enable stack checking (-Xstack-probe) 107
5.4.115 Diagnose static initialization using address (-Xstatic-addr-...) 107
5.4.116 Buffer stderr (-Xstderr-fully-buffered) 107
5.4.117 Select stmw and lmw instructions (-Xstmw-fast, -Xstmw-ok, -Xstmw-slow) 107
5.4.118 Terminate compilation on warning (-Xstop-on-warning) 108
5.4.119 Disable non-EABI conversion functions (-Xstrict-eabi) 108
5.4.120 Align strings on n-byte boundaries (-Xstring-align=n) 108
5.4.121 Warn on large structure (-Xstruct-arg-warning=n) 108
5.4.122 Control optimization of structure member assignments (-Xstruct-assign-split-...) 109
5.4.123 Align data on "natural" boundaries (-Xstruct-best-align) 109
5.4.124 Set minimum structure member alignment (-Xstruct-min-align=n) 110
5.4.125 Select stswi and lswi instructions (-Xstsw-fast, -Xstsw-ok, -Xstsw-slow) 110
5.4.126 Suppress warnings (-Xsuppress-warnings) 110
5.4.127 Swap `\n' and `\r' in constants (-Xswap-cr-nl) 110
5.4.128 Set threshold for a switch statement table (-Xswitch-table...) 111
5.4.129 Disable certain syntax warnings (-Xsyntax-warning-...) 111
5.4.130 Select target processor (-Xtarget) 111
5.4.131 Specify loop test location (-Xtest-at-...) 111
5.4.132 Generate trace table (-Xtrace-table=n) 112
5.4.133 Truncate all identifiers after m characters (-Xtruncate) 112
5.4.134 Append underscore to identifier (-Xunderscore-...) 112
5.4.135 Control loop unrolling (-Xunroll=n, -Xunroll-size=n) 113
5.4.136 Runtime declarations in standard namespace (-Xusing-std-...) 113
5.4.137 Vector code generation (-Xvector-...) 113
5.4.138 Void pointer arithmetic (-Xvoid-ptr-arith-ok) 114
5.4.139 VRSAVE special purpose register (-Xvrsave-...) 114
5.4.140 Define type for wchar (-Xwchar=n) 114
5.4.141 Control use of wchar_t keyword (-Xwchar_t-...) 114
5.5 Examples of processing source files 115
5.5.1 Compile and link 115
5.5.2 Separate compilation 116
5.5.3 Assembly output 117
5.5.4 Precompiled headers 117

6 Additions to ANSI C and C++ 119
6.1 Preprocessor predefined macros 121
6.2 Preprocessor directives 123
6.2.1 #assert and #unassert preprocessor directives 123
6.2.2 #error preprocessor directive 124
6.2.3 #ident preprocessor directive 124
6.2.4 #import preprocessor directive 125
6.2.5 #info, #inform, and #informing preprocessor directives 125
6.2.6 #warn and #warning preprocessor directives 125
6.3 Pragmas 126
6.3.1 align pragma 126
6.3.2 error pragma 126
6.3.3 global_register pragma 127
6.3.4 hdrstop pragma 128
6.3.5 ident pragma 128
6.3.6 info pragma 128
6.3.7 inline pragma 128
6.3.8 interrupt pragma 129
6.3.9 no_alias pragma 130
6.3.10 no_pch pragma 130
6.3.11 no_return pragma 130
6.3.12 no_side_effects pragma 131
6.3.13 option pragma 131
6.3.14 pack pragma 132
6.3.15 pure_function pragma 136
6.3.16 section pragmas 137
6.3.17 use_section pragma 137
6.3.18 warning pragma 137
6.3.19 weak pragma 138
6.4 Keywords 138
6.4.1 __asm and asm keywords 139
6.4.2 __attribute__ keyword 139
6.4.3 extended keyword (C only) 140
6.4.4 __inline__ and inline keywords 140
6.4.5 __interrupt__ and interrupt keywords (C only) 141
6.4.6 long long 142
6.4.7 __packed__ and packed (C only) 142
6.4.8 pascal keyword (C only) 143
6.5 Other additions 144
6.5.1 C++ comments permitted 144
6.5.2 Dynamic memory allocation with alloca 144
6.5.3 Assigning global variables to registers 144
6.5.4 __ERROR__ function 145
6.5.5 Intrinsic functions 146
6.5.6 sizeof extension 147

7 Embedding assembly code 149
7.1 asm macros 151
7.1.1 Comments in asm macros 155
7.1.2 Examples of asm macros 156
7.2 asm string statements 157
7.2.1 Example - disable interrupts 159
7.3 Reordering in asm code 159
7.4 Direct functions 160

8 Internal Data Representation 161
8.1 Basic data types 161
8.2 Byte ordering 163
8.3 Arrays 164
8.4 Bit-fields 164
8.5 Classes, structures, and unions 165
8.6 C++ classes 165
8.6.1 Pointers to members 168
8.6.2 Virtual function table generation - key functions 169
8.7 Linkage and storage allocation 169

9 Calling Conventions 173
9.1 Stack layout 174
9.1.1 EABI stack frame 174
9.1.2 AIX stack frame 175
9.2 Argument passing 176
9.2.1 EABI argument passing 176
9.2.2 AIX argument passing 178
9.3 C++ argument passing 178
9.3.1 Pointer to member as arguments and return types 179
9.3.2 Member function 179
9.3.3 Constructors and destructors 179
9.4 Returning results 180
9.4.1 Class, struct, and union return types 180
9.5 Register use 181

10 Optimization 183
10.1 Optimization hints 184
10.1.1 What to do from the command line 184
10.1.2 What to do with programs 186
10.2 Target-independent optimizations 191
10.2.1 Tail recursion (0x2) 192
10.2.2 Inlining (0x4) 192
10.2.3 Argument address optimization (0x8) 194
10.2.4 Structure members to registers (0x10) 194
10.2.5 Range optimization (0x20) 194
10.2.6 Question - expression pop (0x40) 195
10.2.7 Assignment optimization (0x80) 195
10.2.8 Common tail optimization (0x200) 196
10.2.9 Variable live range optimization (0x400) 196
10.2.10 Constant and variable propagation (0x800) 196
10.2.11 Complex branch optimization (0x1000) 196
10.2.12 Loop strength reduction (0x2000) 197
10.2.13 Loop count-down optimization (0x4000) 198
10.2.14 Loop unrolling (0x8000) 198
10.2.15 Global common subexpression elimination (0x10000) 198
10.2.16 Undefined variable propagation (0x20000) 198
10.2.17 Unused assignment deletion (0x40000) 199
10.2.18 Minor transformations to simplify code generation (0x80000) 199
10.2.19 Register coloring (0x200000) 199
10.2.20 Interprocedural optimizations (0x400000) 199
10.2.21 Remove entry and exit code (0x800000) 199
10.2.22 Use scratch registers for variables (0x1000000) 200
10.2.23 Extend optimization (0x2000000) 201
10.2.24 Loop statics optimization (0x4000000) 201
10.2.25 Loop invariant code motion (0x8000000) 202
10.2.26 Static function optimization (0x20000000) 202
10.2.27 Live-variable analysis (0x40000000) 202
10.2.28 Local static variables optimization (0x80000000) 203
10.2.29 Feedback optimization 203
10.3 Target dependent optimizations 204
10.3.1 Basic reordering (0x1) 204
10.3.2 General peephole optimization (0x8) 204
10.3.3 Peephole reaching analysis (0x20) 205
10.3.4 Merge multiple Add instructions (0x80) 205
10.3.5 Merge common block entry or exit code (0x200) 205
10.3.6 Additional loop optimizations (0x400) 205
10.3.7 rlwinm peephole optimization (0x800) 206
10.3.8 Float-move peephole (0x4000) 206
10.3.9 Vector-move peephole (0x8000) 206
10.4 Example of optimizations 206

11 The Lint Facility 211

12 Converting Existing Code 217
12.1 Compilation issues 217
12.1.1 Older C code 218
12.1.2 Older versions of Diab C++ 218
12.2 Execution issues 219

13 C++ Features and Compatibility 223
13.1 Header files 224
13.2 Migration from C to C++ 224
13.3 Implementation-specific C++ features 225
13.3.1 Construction and destruction of C++ static objects 225
13.3.2 Templates 225
13.3.3 Exceptions 227
13.3.4 Array new and delete 227
13.3.5 Type identification 227
13.3.6 Dynamic casts in C++ 227
13.3.7 Namespaces 227
13.4 C++ name mangling 228
13.4.1 Demangling utility 230
13.5 Avoid setjmp and longjmp 231
13.6 Precompiled headers 231
13.6.1 PCH files 232
13.6.2 Limitations and tradeoffs 233
13.6.3 Diagnostics 233

14 Locating Code and Data, Addressing, and Access 235
14.1 Controlling access to code and data 235
14.1.1 section and use_section pragmas 236
14.2 Addressing mode - functions, variables, strings 239
14.3 Access mode - read, write, execute 242
14.4 Local data area (-Xlocal-data-area) 250
14.5 Position-independent code and data (PIC and PID) 251
14.5.1 Generating initializers for static variables with position-independent code 253
14.5.2 Relationship between position-independence and "small" areas 253

15 Use in an Embedded Environment 255
15.1 Compiler options for embedded development 257
15.2 User modifications 258
15.3 Startup and termination code 258
15.3.1 Location of startup and termination sources and objects 260
15.3.2 Notes for crt0.s 260
15.3.3 Notes for init.c 261
15.3.4 Notes for exit functions 262
15.3.5 Stack initialization and checking 263
15.3.6 Dynamic memory allocation - the heap, malloc( ), sbrk( ) 264
15.3.7 Run-time initialization and termination 265
15.4 Hardware exception handling 266
15.5 Library exception handling 266
15.5.1 Error handling by the Run-Time Error Checker 267
15.6 Linker command file 268
15.7 Operating system calls 269
15.7.1 Character I/O 269
15.7.2 File I/O 270
15.7.3 Miscellaneous functions 271
15.8 Communicating with the hardware 272
15.8.1 Mixing C and assembler functions 272
15.8.2 Embedding assembler code 272
15.8.3 Accessing variables and functions at specific addresses 273
15.9 Reentrant and "thread-safe" library functions 274
15.10 Target program arguments, environment variables, and predefined files 275
15.11 Profiling in an embedded environment 277
15.12 Support for multiple object formats 279

 Diab Assembler    281

16 The Diab Assembler 283
16.1 Selecting the target 283
16.2 The das command 284
16.3 Assembler command line options 284
16.3.1 Define symbol name (-Dname=value) 285
16.3.2 Generate debugging information (-g) 285
16.3.3 Include header in listing (-H) 285
16.3.4 Set header files directory (-I path) 285
16.3.5 Generate listing file (-l, -L) 286
16.3.6 Set output file (-o file) 286
16.3.7 Remove the input file on termination (-R) 286
16.3.8 Specify assembler description (.ad) file (-T ad-file) 286
16.3.9 Select target (-ttof:environ) 286
16.3.10 Print version number (-V) 287
16.3.11 Define configuration variable (-WDname=value) 287
16.3.12 Select object format and mnemonic type (-WDDOBJECT=object-format) 287
16.3.13 Select target processor (-WDDTARGET=target) 287
16.3.14 Discard all local symbols (-x) 287
16.3.15 Discard all symbols starting with .L (-X) 288
16.3.16 Print command line options on standard output (-#) 288
16.3.17 Read command line options from file or variable (-@name, -@@name) 288
16.3.18 Redirect output (-@E=file, -@E+file, -@O=file, -@O+file) 288
16.4 Assembler -X options 289
16.4.1 Specify value to fill gaps left by .align or .alignn directive (-Xalign-fill-text) 289
16.4.2 Interpret .align directive (-Xalign-value, -Xalign-power2) 289
16.4.3 Generate debugging information (-Xasm-debug-... ) 289
16.4.4 Align program data automatically based on size (-Xauto-align) 289
16.4.5 Set instruction type (-Xcpu-...) 290
16.4.6 Set default value for section alignment (-Xdefault-align) 290
16.4.7 Generate NOP for certain branch conditional instructions (-Xfix-bc-fw-mask-bug) 290
16.4.8 Enable local GNU labels (-Xgnu-locals-...) 291
16.4.9 Include header in listing (-Xheader...) 291
16.4.10 Set header format (-Xheader-format="string") 291
16.4.11 Set label definition syntax (-Xlabel-colon...) 292
16.4.12 Set format of assembly line in listing (-Xline-format="string") 292
16.4.13 Generate a listing file (-Xlist-...) 293
16.4.14 Set line length of listing file (-Xllen=n) 293
16.4.15 Enable blanks in macro arguments (-Xmacro-arg-space-...) 293
16.4.16 Set output object format (-Xobject-format=form) 294
16.4.17 Select branch size optimizations (-Xoptim-...) 294
16.4.18 Set page break margin (-Xpage-skip=n) 294
16.4.19 Set lines per page (-Xplen=n) 295
16.4.20 Limit length of conditional branch(-Xprepare-compress=n) 295
16.4.21 Treat semicolons as statement separators (-Xsemi-is-newline) 295
16.4.22 Enable spaces between operands (-Xspace-...) 295
16.4.23 Delete local symbols (-Xstrip-locals..., -Xstrip-temps...) 295
16.4.24 Set subtitle (-Xsubtitle="string") 296
16.4.25 Set tab size (-Xtab-size=n) 296
16.4.26 Set title (-Xtitle="string") 296

17 Syntax Rules 297
17.1 Format of an Assembly Language Line 298
17.1.1 Labels 298
17.1.2 Opcode 299
17.1.3 Operand field 299
17.1.4 Comment 300
17.2 Symbols 300
17.3 Direct assignment statements 301
17.4 External symbols 301
17.5 Local symbols 302
17.5.1 Generic style locals 303
17.5.2 GNU-style locals 303
17.6 Constants 304
17.6.1 Integral Constants 304
17.6.2 Floating Point Constants 305
17.6.3 String constants 305

18 Sections and Location Counters 307
18.1 Program sections 307
18.2 Location counters 309

19 Assembler Expressions 311

20 Assembler Directives 317
20.1 symbol[:] = expression 318
20.2 symbol[:] =: expression 318
20.3 .2byte 318
20.4 .4byte 318
20.5 .align expression 318
20.6 .alignn expression 319
20.7 .ascii "string" 320
20.8 .asciz "string" 320
20.9 .balign expression 320
20.10 .blkb expression 320
20.11 .bss 321
20.12 .bsect 321
20.13 .byte expression ,... 321
20.14 .comm symbol, size [,alignment] 321
20.15 dc.b expression 322
20.16 dc.l expression 322
20.17 dc.w expression 323
20.18 ds.b size 323
20.19 .data 323
20.20 .double float-constant ,... 323
20.21 .dsect 323
20.22 .eject 324
20.23 .else 324
20.24 .elseif expression 324
20.25 .elsec 324
20.26 .end 325
20.27 .endc 325
20.28 .endif 325
20.29 .endm 325
20.30 .entry symbol ,... 325
20.31 symbol[:] .equ expression 326
20.32 .error "string" 326
20.33 .even 326
20.34 .exitm 326
20.35 .extern symbol ,... 327
20.36 .export symbol ,... 327
20.37 .file "file" 327
20.38 .fill count,[size[,value]] 327
20.39 .float float-constant ,... 328
20.40 .global symbol ,... 328
20.41 .globl symbol ,... 328
20.42 .ident "string" 328
20.43 .if expression 329
20.44 .ifendian 329
20.45 .ifeq expression 330
20.46 .ifc "string1","string2" 330
20.47 .ifdef symbol 330
20.48 .ifge expression 330
20.49 .ifgt expression 331
20.50 .ifle expression 331
20.51 .iflt expression 331
20.52 .ifnc "string1","string2" 331
20.53 .ifndef symbol 332
20.54 .ifne expression 332
20.55 .import symbol ,... 332
20.56 .include "file" 332
20.57 .lcnt expression 332
20.58 .lcomm symbol, size [,alignment] 333
20.59 .list 333
20.60 .llen expression 333
20.61 .llong expression ,... 334
20.62 .long expression ,... 334
20.63 name .macro [parameter ,...] 334
20.64 .mexit 335
20.65 .name "file" 335
20.66 .nolist 335
20.67 .org expression 335
20.68 .p2align expression 336
20.69 .page 336
20.70 .pagelen expression 336
20.71 .plen expression 336
20.72 .previous 337
20.73 .psect 337
20.74 .psize page-length [,line-length] 337
20.75 .rdata 337
20.76 .rodata 338
20.77 .sbss [symbol, size [,alignment]] 338
20.78 .sbttl "string" 338
20.79 .sdata 338
20.80 .sdata2 339
20.81 .section name, [alignment], [type] 339
20.82 .section n 340
20.83 .sectionlink section-name 340
20.84 .set option 341
20.85 .set symbol, expression 341
20.86 symbol[:] .set expression 341
20.87 .short expression ,... 342
20.88 .size symbol, expression 342
20.89 .skip size 342
20.90 .space expression 343
20.91 .string "string" 343
20.92 .strz "string" 343
20.93 .subtitle "string" 343
20.94 .text 344
20.95 .title "string" 344
20.96 .ttl "string" 344
20.97 .type symbol, type 344
20.98 .uhalf 345
20.99 .ulong 345
20.100 .ushort 345
20.101 .uword 346
20.102 .warning "string" 346
20.103 .weak symbol ,... 346
20.104 .width expression 346
20.105 .word expression ,... 347
20.106 .xdef symbol ,... 347
20.107 .xref symbol ,... 347
20.108 .xopt 347

21 Assembler Macros 349
21.1 Macro definition 350
21.1.1 Separating parameter names from text 352
21.1.2 Generating unique labels 352
21.1.3 NARG symbol 353
21.2 Invoking a macro 353
21.3 Macros to "define" structures 354

22 Example Assembler Listing 357

 Diab Linker    359

23 The Diab Linker 361
23.1 The linking process 362
23.1.1 Linking example 363
23.2 Symbols created by Diab Linker 366
23.3 ".abs" sections 369
23.4 COMMON sections 369
23.5 COMDAT sections 370
23.6 Sorted sections 371
23.7 Warning sections 371
23.8 Branch islands 372

24 The dld Command 375
24.1 The dld command 375
24.1.1 Linker command structure 376
24.2 Defaults 378
24.3 Order on the command line 379
24.4 Linker command line options 380
24.4.1 Read options from an environment variable or file (-@name) 380
24.4.2 Link files from an archive (-A name) 380
24.4.3 Allocate memory for common variables when using -r (-a) 380
24.4.4 Set address for data and text (-Bd=address, -Bt=address) 381
24.4.5 Define a default entry point address (-e symbol) 381
24.4.6 Specify "fill" value (-f value) 382
24.4.7 Specify directory for -l search list (-L dir) 382
24.4.8 Specify library or file to process (-lname, -l:filename) 382
24.4.9 Generate link map (-m, -m2, -m4) 383
24.4.10 Allocate .data section immediately after .text section (-N) 383
24.4.11 Change the default output file (-o file) 383
24.4.12 Perform incremental link (-r, -r2, -r3, -r4) 383
24.4.13 Rename symbols (-R symbol1=symbol2) 384
24.4.14 Do not output symbol table and line number entries (-s, -ss) 384
24.4.15 Select target processor and environment (-t tof:environ) 384
24.4.16 Define a symbol (-u symbol) 385
24.4.17 Print version number (-V) 385
24.4.18 Print version number (-VS value) 385
24.4.19 Do not output some symbols (-X, -x) 385
24.4.20 Specify search directories for -l (-Y L, -Y P, -Y U) 385
24.4.21 Read command line options from file or environment variable (-@name, -@@name) 386
24.4.22 Redirect output (-@E=file, -@E+file, -@O=file, -@O+file) 386
24.5 Linker -X options 387
24.5.1 Generate program headers (-Xassociate-headers) 387
24.5.2 Enable/disable branch island generation (-Xbranch-islands...) 387
24.5.3 Check input patterns (-Xcheck-input-patterns) 387
24.5.4 Check for overlapping output sections (-Xcheck-overlapping) 388
24.5.5 Use COFF format for output file (-Xcoff...) 388
24.5.6 Align common symbols (-Xcommon-align=n) 388
24.5.7 Remove multiple structure definitions (-Xcompress-symbols) 388
24.5.8 Force linker to continue after errors (-Xdont-die) 389
24.5.9 Do not create output file (-Xdont-link) 389
24.5.10 Use ELF format for output file (-Xelf) 389
24.5.11 ELF format relocation information (-Xelf-rela-...) 389
24.5.12 Write explicit instantiations file (-Xexpl-instantiations) 390
24.5.13 Generate executable for conversion to IEEE-695 (-Xextern-in-place) 390
24.5.14 Store segment address in program header (-Xgenerate-paddr) 390
24.5.15 Generate RTA information (-Xgenerate-vmap) 390
24.5.16 Limit long branch island generation (-Xmax-long-branch) 391
24.5.17 Limit short branch island generation (-Xmax-short-branch) 391
24.5.18 Allow mixed compression (-Xmixed-compression) 391
24.5.19 Do no align output section (-Xold-align) 392
24.5.20 Pad input sections to match existing executable file (-Xoptimized-load) 392
24.5.21 Make branch islands position-independent (-Xpic-only) 392
24.5.22 Add leading underscore `_' to all symbols (-Xprefix-underscore...) 393
24.5.23 Use workaround for ELF relocation bug (-Xreloc-bug) 393
24.5.24 Remove unused sections (-Xremove-unused-sections) 393
24.5.25 Re-scan libraries (-Xrescan-libraries...) 394
24.5.26 Re-scan libraries restart (-Xrescan-restart...) 394
24.5.27 Align sections (-Xsection-align=n) 394
24.5.28 Stop on warning (-Xstop-on-warning) 395
24.5.29 Suppress leading dots `.' (-Xsuppress-dot...) 395
24.5.30 Suppress section names (-Xsuppress-section-names) 395
24.5.31 Suppress paths in symbol table (-Xsuppress-path) 395
24.5.32 Suppress leading underscores `_' (-Xsuppress-underscore-...) 395
24.5.33 Remove/keep unused sections (-Xunused-sections...) 396

25 Linker Command Language 397
25.1 Example "bubble.dld" 398
25.2 Syntax notation 400
25.3 Numbers 401
25.4 Symbols 401
25.5 Expressions 402
25.6 Command file structure 403
25.7 MEMORY command 404
25.8 SECTIONS command 405
25.8.1 Section-definition 405
25.8.2 GROUP definition 415
25.9 Assignment command 416
25.10 Examples 417

 Diab C/C++ Utilities    431

26 Utilities 433
26.1 Common command line options 433
26.1.1 Read command line options from file or variable (-@name, -@@name) 434
26.1.2 Redirect output (-@E=file, -@E+file, -@O=file, -@O+file) 434

27 D-AR Archiver 435
27.1 Synopsis 435
27.2 Syntax 435
27.3 Description 436
27.4 Examples 439

28 D-BCNT Program Profiling Basic Block Counter 441
28.1 Synopsis 441
28.2 Syntax 441
28.3 Description 442
28.4 Files 443
28.5 Examples 443
28.6 Coverage 444
28.7 Notes 444

29 D-DUMP File Dumper 445
29.1 Synopsis 445
29.2 Syntax 445
29.3 Description 446
29.4 Examples 453

30 dmake Makefile Utility 455
30.1 Installation 455
30.2 Using dmake 456

31 WindISS Simulator and Disassembler 457
31.1 Synopsis 458
31.2 Simulator mode 458
31.2.1 Syntax (simulator mode) 458
31.2.2 Compiling for the windiss simulator 459
31.2.3 Description 460
31.3 Batch disassembler mode 464
31.3.1 Syntax (disassembler mode) 464
31.3.2 Description 465
31.4 Interactive disassembler mode 465
31.4.1 Syntax (interactive disassembler mode) 465
31.4.2 Description 465
31.5 Examples 466

 C Library    471

32 Library Structure, Rebuilding 473
32.1 Introduction 473
32.2 Library structure 474
32.2.1 Libraries supplied 474
32.2.2 Library directory structure 478
32.2.3 libc.a 480
32.2.4 Library search paths 481
32.3 Library sources, rebuilding the libraries 484
32.3.1 Sources 484
32.3.2 Rebuilding the libraries 485

33 Header Files 487
33.1 Files 488
33.2 Defined Variables, Types, and Constants 490
33.2.1 errno.h 490
33.2.2 fcntl.h 490
33.2.3 float.h 491
33.2.4 limits.h 491
33.2.5 math.h 491
33.2.6 mathf.h 491
33.2.7 setjmp.h 491
33.2.8 signal.h 491
33.2.9 stdarg.h 491
33.2.10 stddef.h 492
33.2.11 stdio.h 492
33.2.12 stdlib.h 492
33.2.13 string.h 492
33.2.14 time.h 492

34 C Library Functions 493
34.1 Format of Descriptions 493
34.1.1 Operating system calls 494
34.1.2 References 494
34.2 Reentrant Versions 495
34.3 Function Listing 495
a64l( ) 496
abort( ) 496
abs( ) 496
access( ) 496
acos( ) 497
acosf( ) 497
advance( ) 497
asctime( ) 497
asin( ) 498
asinf( ) 498
assert( ) 498
atan( ) 499
atanf( ) 499
atan2( ) 499
atan2f( ) 500
atexit( ) 500
atof( ) 500
atoi( ) 500
atol( ) 501
bsearch( ) 501
calloc( ) 501
ceil( ) 501
ceilf( ) 502
_chgsign( ) 502
clearerr( ) 502
clock( ) 502
close( ) 503
compile( ) 503
_copysign( ) 503
cos( ) 504
cosf( ) 504
cosh( ) 504
coshf( ) 504
creat( ) 505
ctime( ) 505
difftime( ) 505
div( ) 505
drand48( ) 506
dup( ) 506
ecvt( ) 506
erf( ) 507
erff( ) 507
erfc( ) 507
erfcf( ) 507
exit( ) 508
_exit( ) 508
exp( ) 508
expf( ) 509
fabs( ) 509
fabsf( ) 509
fclose( ) 509
fcntl( ) 510
fcvt( ) 510
fdopen( ) 510
feof( ) 510
ferror( ) 511
fflush( ) 511
fgetc( ) 511
fgetpos( ) 511
fgets( ) 512
fileno( ) 512
_finite( ) 512
floor( ) 512
floorf( ) 513
fmod( ) 513
fmodf( ) 513
fopen( ) 513
fprintf( ) 514
fputc( ) 514
fputs( ) 515
fread( ) 515
free( ) 515
freopen( ) 516
frexp( ) 516
frexpf( ) 516
fscanf( ) 517
fseek( ) 517
fsetpos( ) 517
fstat( ) 518
ftell( ) 518
fwrite( ) 518
gamma( ) 518
gammaf( ) 519
gcvt( ) 519
getc( ) 519
getchar( ) 520
getenv( ) 520
getopt( ) 520
getpid( ) 521
gets( ) 521
getw( ) 521
gmtime( ) 521
hcreate( ) 522
hdestroy( ) 522
hsearch( ) 522
hypot( ) 523
hypotf( ) 523
irand48( ) 523
isalnum( ) 523
isalpha( ) 524
isascii( ) 524
isatty( ) 524
iscntrl( ) 524
isdigit( ) 525
isgraph( ) 525
islower( ) 525
_isnan( ) 525
isprint( ) 525
ispunct( ) 526
isspace( ) 526
isupper( ) 526
isxdigit( ) 526
j0( ) 527
j0f( ) 527
j1( ) 527
j1f( ) 527
jn( ) 528
jnf( ) 528
jrand48( ) 528
kill( ) 528
krand48( ) 529
l3tol( ) 529
l64a( ) 529
labs( ) 529
lcong48( ) 530
ldexp( ) 530
ldexpf( ) 530
ldiv( ) 530
_lessgreater( ) 531
lfind( ) 531
link( ) 531
localeconv( ) 531
localtime( ) 532
log( ) 532
_logb( ) 532
logf( ) 532
log10( ) 533
log10f( ) 533
longjmp( ) 533
lrand48( ) 533
lsearch( ) 534
lseek( ) 534
ltol3( ) 535
mallinfo( ) 535
malloc( ) 535
__malloc_set_block_size( ) 536
mallopt( ) 536
matherr( ) 536
matherrf( ) 537
mblen( ) 538
mbstowcs( ) 538
mbtowc( ) 538
memccpy( ) 539
memchr( ) 539
memcmp( ) 539
memcpy( ) 539
memmove( ) 540
memset( ) 540
mktemp( ) 540
mktime( ) 540
modf( ) 541
modff( ) 541
mrand48( ) 541
_nextafter ( ) 541
nrand48( ) 542
offsetof( ) 542
open( ) 542
perror( ) 543
pow( ) 543
powf( ) 543
printf( ) 544
putc( ) 546
putchar( ) 546
putenv( ) 547
puts( ) 547
putw( ) 547
qsort( ) 548
raise( ) 548
rand( ) 548
read( ) 548
realloc( ) 549
remove( ) 549
rename( ) 549
rewind( ) 550
sbrk( ) 550
_scalb( ) 550
scanf( ) 550
seed48( ) 552
setbuf( ) 552
setjmp( ) 553
setlocale( ) 553
setvbuf( ) 554
signal( ) 554
sin( ) 554
sinf( ) 555
sinh( ) 555
sinhf( ) 555
sprintf( ) 555
sqrt( ) 556
sqrtf( ) 556
srand( ) 556
srand48( ) 556
sscanf( ) 557
step( ) 557
strcat( ) 557
strchr( ) 557
strcmp( ) 558
strcoll( ) 558
strcpy( ) 558
strcspn( ) 558
strdup( ) 559
strerror( ) 559
strftime( ) 559
strlen( ) 560
strncat( ) 560
strncmp( ) 561
strncpy( ) 561
strpbrk( ) 561
strrchr( ) 562
strspn( ) 562
strstr( ) 562
strtod( ) 562
strtok( ) 563
strtol( ) 563
strtoul( ) 563
strxfrm( ) 564
swab( ) 564
tan( ) 564
tanf( ) 565
tanh( ) 565
tanhf( ) 565
tdelete( ) 565
tell( ) 566
tempnam( ) 566
tfind( ) 566
time( ) 566
tmpfile( ) 567
tmpnam( ) 567
toascii( ) 567
tolower( ) 568
_tolower( ) 568
toupper( ) 568
_toupper( ) 568
tsearch( ) 569
twalk( ) 569
tzset( ) 569
ungetc( ) 570
unlink( ) 570
_unordered( ) 570
vfprintf( ) 570
vfscanf( ) 571
vprintf( ) 571
vscanf( ) 572
vsprintf( ) 572
vsscanf( ) 572
wcstombs( ) 573
wctomb( ) 573
write( ) 573
y0( ) 574
y0f( ) 574
y1( ) 574
y1f( ) 574
yn( ) 575
ynf( ) 575

 Appendices    577

A Configuration Files 579
A.1 What are configuration files 580
A.2 How commands, environment variables, and configuration files relate 580
A.2.1 Configuration variables and precedence 581
A.2.2 Startup 581
A.3 Standard configuration files 583
A.3.1 DENVIRON configuration variable 584
A.3.2 UFLAGS1, UFLAGS2, DFLAGS configuration variables 586
A.3.3 UAFLAGS1, UAFLAGS2, ULFLAGS1, ULFLAGS2 configuration variables 587
A.4 The configuration language 588
A.4.1 Statements and options 588
A.4.2 Comments 589
A.4.3 String constants 589
A.4.4 Variables 590
A.4.5 Assignment statement 591
A.4.6 Error statement 592
A.4.7 Exit statement 592
A.4.8 If statement 592
A.4.9 Include statement 593
A.4.10 Print statement 593
A.4.11 Switch statement 593

B C Compatibility Modes: ANSI, PCC, and K&R C 595

C Compiler Limits 601

D Compiler Implementation Defined Behavior 603
D.1 Translation 603
D.2 Environment 606
D.3 Library functions 607

E Assembler Coding Notes 611
E.1 Instruction Mnemonics 611
E.2 Operand Addressing Modes 612
E.2.1 Registers 612
E.2.2 Expressions 612

F Executable and Linking Format (ELF) 615
F.1 Overall structure 616
F.2 ELF header 617
F.3 Program header 618
F.4 Section headers 620
F.5 Special sections 622
F.6 Relocation information 623
F.7 Line number information 627
F.8 Symbol table 627
F.9 String table 628

G Common Object File Format (COFF) 629
G.1 Overall structure 630
G.2 File header 632
G.3 Optional header 633
G.4 Section headers 634
G.5 Raw data sections 636
G.6 COFF relocation information 637
G.7 Line number information 639
G.8 Symbol table 641
G.9 Additional symbols 643
G.10 String table 643

H Compiler -X Options Numeric List 645

I Messages 649
I.1 Compiler messages 650
I.1.1 Message format 650
I.1.2 Errors in asm macros and asm strings 651
I.1.3 C compiler message detail 651
I.2 Assembler messages 717
I.3 Linker messages 718

Index 719

 

support@windriver.com
Copyright © 2002, Wind River Systems, Inc. All rights reserved.