GCC-ERC32 User's Guide

C/C++ Compilation System for Spacecraft Microprocessors

Free Software Foundation

Chris Nettleton

License

XGC is commercial non-proprietary software distributed under the terms of the GNU Public license. Permission is granted to make and distribute verbatim copies of this document provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this document under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this document into another language, under the above conditions for modified versions.

Trademarks

Sun and Solaris are registered trademarks of Sun Microsystems, Inc. UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company, Ltd. X/Open is a trademark of X/Open Company Limited. Windows is a registered trademark of Microsoft Corporation.

All other trademarks and registered trademarks are the property of their respective holders.

Acknowledgements

GCC-ERC32 is based on the GCC compiler from the Free Software Foundation, Cambridge, Massachusetts.

GCC-ERC32 was developed under contract with the European Space Agency, contract number 11935/NL/JG.


Table of Contents
About this Guide
Audience
Organization
Related Documents
Reader's Comments
Documentation Conventions
I. Using the C/C++ Compiler
1. Compiler Options
1.1. Option Summary
1.2. Options Controlling the Kind of Output
1.3. Compiling C++ Programs
1.4. Options Controlling C Dialect
1.5. Options Controlling C++ Dialect
1.6. Options to Request or Suppress Warnings
1.7. Options for Debugging Your Program or the compiler
1.8. Options that Control Optimization
1.9. Options Controlling the Preprocessor
1.10. Passing Options to the Assembler
1.11. Options for Linking
1.12. Options for Directory Search
1.13. Hardware Models and Configurations
1.14. Options for Code Generation Conventions
1.15. Environment Variables Affecting the Compiler
1.16. Running Protoize
2. Extensions to the C Language Family
2.1. Statements and Declarations in Expressions
2.2. Locally Declared Labels
2.3. Labels as Values
2.4. Nested Functions
2.5. Constructing Function Calls
2.6. Naming an Expression's Type
2.7. Referring to a Type with typeof
2.8. Generalized Lvalues
2.9. Conditionals with Omitted Operands
2.10. Double-Word Integers
2.11. Complex Numbers
2.12. Arrays of Length Zero
2.13. Arrays of Variable Length
2.14. Macros with Variable Numbers of Arguments
2.15. Non-Lvalue Arrays May Have Subscripts
2.16. Arithmetic on void- and Function-Pointers
2.17. Non-Constant Initializers
2.18. Constructor Expressions
2.19. Labeled Elements in Initializers
2.20. Case Ranges
2.21. Cast to a Union Type
2.22. Declaring Attributes of Functions
2.23. Prototypes and Old-Style Function Definitions
2.24. C++ Style Comments
2.25. Dollar Signs in Identifier Names
2.26. The Escape Character in Constants
2.27. Inquiring on Alignment of Types or Variables
2.28. Specifying Attributes of Variables
2.29. Specifying Attributes of Types
2.30. An Inline Function is As Fast As a Macro
2.31. Assembler Instructions with C Expression Operands
2.32. Constraints for asm Operands
2.33. Controlling Names Used in Assembler Code
2.34. Variables in Specified Registers
2.35. Alternate Keywords
2.36. Incomplete enum Types
2.37. Function Names as Strings
2.38. Getting the Return or Frame Address of a Function
3. Extensions to the C++ Language
3.1. Named Return Values in C++
3.2. Minimum and Maximum Operators in C++
3.3. goto and Destructors in GNU C++
3.4. Declarations and Definitions in One Header
3.5. Where's the Template?
3.6. Type Abstraction using Signatures
4. Comments on the Compiler
4.1. Incompatibilities of the compiler
4.2. Standard Libraries
4.3. Disappointments and Misunderstandings
4.4. Common Misunderstandings with GNU C++
4.5. Caveats of using protoize
4.6. Certain Changes We Don't Want to Make
4.7. Warning Messages and Error Messages
II. Running and Debugging C and C++ Programs
5. Using the Simulator
5.1. The Command Line
5.2. Command Line Switches
5.3. Examples of Simulator Use
6. Summary of the Debugger
7. A Sample Debug Session
8. Getting In and Out of the Debugger
8.1. Invoking the Debugger
8.2. Quitting the Debugger
8.3. Shell Commands
9. Debugger Commands
9.1. Command Syntax
9.2. Command Completion
9.3. Getting Help
10. Running Programs Under the Debugger
10.1. Compiling for Debugging
10.2. Starting your Program
11. Stopping and Continuing
11.1. Breakpoints, Watchpoints, and Exceptions
11.2. Continuing and Stepping
11.3. Signals
12. Examining the Stack
12.1. Stack Frames
12.2. Backtraces
12.3. Selecting a Frame
12.4. Information about a Frame
13. Examining Source Files
13.1. Printing Source Lines
13.2. Searching Source Files
13.3. Specifying Source Directories
13.4. Source and Machine Code
14. Examining Data
14.1. Expressions
14.2. Program Variables
14.3. Artificial Arrays
14.4. Output Formats
14.5. Examining Memory
14.6. Automatic Display
14.7. Print Settings
14.8. Value History
14.9. Convenience Variables
14.10. Registers
15. Using the Debugger with Different Languages
15.1. Switching Between Source Languages
15.2. Displaying the Language
15.3. Supported Languages
16. Examining the Symbol Table
17. Altering Execution
17.1. Assignment to Variables
17.2. Continuing at a Different Address
17.3. Returning from a Function
17.4. Calling Program Functions
17.5. Patching Programs
18. The Debugger Files
18.1. Commands to Specify Files
18.2. Errors Reading Symbol Files
19. Specifying a Debugging Target
19.1. Active Targets
19.2. Commands for Managing Targets
19.3. Remote Debugging
20. Controlling the Debugger
20.1. Prompt
20.2. Command Editing
20.3. Command History
20.4. Screen Size
20.5. Numbers
20.6. Optional Warnings and Messages
21. Canned Sequences of Commands
21.1. User-Defined Commands
21.2. User-Defined Command Hooks
21.3. Command Files
21.4. Commands for Controlled Output
22. Using History Interactively
22.1. History Interaction
III. Using the Macro Assembler
23. Overview
23.1. The Assembler
23.2. Object File Formats
23.3. Command Line
23.4. Input Files
23.5. Output (Object) File
23.6. Error and Warning Messages
24. Assembler Command-Line Options
24.1. Enable Listings: -a[cdhlns]
24.2. -D
24.3. Work Faster: -f
24.4. .include search path: -I path
24.5. Difference Tables: -K
24.6. Include Local Labels: -L
24.7. Name the Object File: -o
24.8. Join Data and Text Sections: -R
24.9. Display Assembly Statistics: --statistics
24.10. Announce Version: -v
24.11. Suppress Warnings: -W
24.12. Generate Object File in Spite of Errors: -Z
25. Assembler Syntax
25.1. Preprocessing
25.2. White-space
25.3. Comments
25.4. Symbols
25.5. Statements
25.6. Constants
26. Sections and Relocation
26.1. Background
26.2. Linker Sections
26.3. Sub-Sections
26.4. bss Section
27. Assembler Symbols
27.1. Labels
27.2. Giving Symbols Other Values
27.3. Symbol Names
27.4. The Special Dot Replaceable
27.5. Symbol Attributes
28. Assembler Expressions
28.1. Empty Expressions
28.2. Integer Expressions
29. Assembler Directives
29.1. .abort
29.2. .ABORT
29.3. .align abs-expr, abs-expr, abs-expr
29.4. .app-file string
29.5. .ascii "string"...
29.6. .asciz "string"...
29.7. .balign[wl] abs-expr, abs-expr, abs-expr
29.8. .byte expressions
29.9. .comm symbol, length
29.10. .data subsection
29.11. .def name
29.12. .dim
29.13. .double flonums
29.14. .eject
29.15. .else
29.16. .endef
29.17. .endif
29.18. .equ symbol, expression
29.19. .equiv symbol, expression
29.20. .err
29.21. .extern
29.22. .file string
29.23. .fill repeat, size, value
29.24. .float flonums
29.25. .global symbol, .globl symbol
29.26. .hword expressions
29.27. .ident
29.28. .if absolute expression
29.29. .include "file"
29.30. .int expressions
29.31. .irp symbol, values...
29.32. .irpc symbol,values...
29.33. .lcomm symbol, length
29.34. .lflags
29.35. .line line-number
29.36. .linkonce [type]
29.37. .ln line-number
29.38. .list
29.39. .long expressions
29.40. .macro
29.41. .nolist
29.42. .octa bignums
29.43. .org new-lc, fill
29.44. .p2align[wl] abs-expr, abs-expr, abs-expr
29.45. .psize lines, columns
29.46. .quad bignums
29.47. .rept count
29.48. .sbttl "sub heading"
29.49. .scl class
29.50. .section name, subsection
29.51. .set symbol, expression
29.52. .short expressions
29.53. .single flonums
29.54. .size
29.55. .skip size, fill
29.56. .space size, fill
29.57. .stabd, .stabn, .stabs
29.58. .string "str"
29.59. .tag structname
29.60. .text subsection
29.61. .title "heading"
29.62. .type int
29.63. .val addr
29.64. .word expressions
29.65. Deprecated Directives
30. Target Dependent Features
30.1. ERC32 Options
30.2. Enforcing aligned data
30.3. Floating Point
30.4. ERC32 Machine Directives
IV. Using the Linker
31. Linker Overview
32. Linker Invocation
32.1. Command Line Options
32.2. Environment Variables
33. Linker Command Language
33.1. Linker Scripts
33.2. Expressions
33.3. Memory Layout
33.4. Specifying Output Sections
33.5. The Entry Point
33.6. Version Script
33.7. Option Commands
V. Using the Object Code Utilities
34. The Utilities
34.1. ar
34.2. nm
34.3. objcopy
34.4. objdump
34.5. ranlib
34.6. size
34.7. strings
34.8. strip
34.9. c++filt
34.10. addr2line
35. Selecting the target system
35.1. Target Selection
35.2. Architecture selection
35.3. Linker emulation selection
VI. Appendices
A. BFD
A.1. How it Works: An Outline of BFD
B. Acknowledgments
B.1. Contributors to GCC
B.2. Contributors to GDB
B.3. Contributors to the Assembler
C. Funding Free Software
D. Protect Your Freedom — Fight "Look and Feel"
Index