File-scope header

Statements in the file-scope header apply to the entire compilation unit and might have the following statements:
  • TITLE statement to specify the product information of the compiler and the source file being compiled.
  • ALIAS/EXTRN statement to declare the external symbols that are referenced in the program, if the LONGNAME compiler option is in effect.
  • CSECT statement to identify the relocatable control section in the program.
  • AMODE statement to specify the addressing mode.
  • RMODE statement to specify the residency mode for running the module.
  • Assembly statements to declare the HLASM global SET symbols used by the compiler-generated code for communicating information to the user-embedded prolog and epilog code, if the compiler detects user-embedded prolog and epilog code.
  • SYSSTATE ARCHLVL statement, which identifies the minimum hardware requirement. SYSSTATE ARCHLVL=3, if and only if ARCH(7) or up and OSREL(ZOSV2R1) or higher are in effect; otherwise, SYSSTATE ARCHLVL=2.
  • IEABRCX DEFINE statement ensures that all branch instructions are changed to relative-branching instructions, in the event that the XL C compiler encounters user-embedded assembly statements.
  • Prefix data to embed a compiler signature and to record attributes about the compilation.

Prefix data

Prefix data is generated to supply a signature, the timestamp of the compilation date, the compiler version, and some control flags. It is placed at the beginning of the code that follows an instruction for branching around the prefix data.

Note: Program code should reference ENTRY rather than CSECT to avoid unnecessary branching.

The prefix data consists of a fixed part (36 bytes in size) followed by a contiguous optional part, with the presence of optional fields indicated by flag bits in flag set 4. Optional fields, if present, are stored immediately following the fixed part of the prefix data aligned on halfword boundaries in the order specified by the left to right bits in flag set 4.

Figure 1 shows the prefix data fixed area fields and definitions.
Figure 1. Prefix data fixed area fields
Prefix data fixed area fields
Signature
An 8-byte field that is set to 0x00C300C300D50000. The last byte in the signature is the version number which can change in future releases.
Compile date
An 8-byte field that contains the date of the compile in YYYYMMDD format.
Compile time
A 6-byte field that contains the time of the compile in HHMMSS format.
Compiler version
A 4-byte field that contains the binary value of the compiler version and release.
Flag Set 1
Flag definition
'.1......'
Compiled with RENT option.
'.0......'
Compiled with NORENT option.
'0.000000'
Reserved.
Flag Set 2
Flag definition
'00000000'
Reserved.
Flag Set 3
Flag definition
'00000000'
Reserved.
Flag Set 4
Flag definition
'1.......'
Indicates the presence of a user comment string.
'0.......'
Indicates no optional user comment string.
'.1......'
Indicates the presence of a service string.
'.0......'
Indicates no service string.
'..1.....'
Indicates the presence of the offset of the end of the current CSECT.
'..0.....'
Indicates no offset of the end of the current CSECT.
'...1....'
Indicates the presence of the offset of the debug information block.
'...0....'
Indicates no offset of the debug information block.
'….0000'
Reserved.
There are four optional prefix data fields, whose presence is indicated by a flag bit in flag set 4.
Length of User Comment String
User Comment String: The user comment string comes from the string specified in both or one of #pragma comment(copyright, "...") and #pragma comment(user, "..."). If you have either or both #pragma, the flag bit is set to one, and the user comment string contains the concatenated strings from multiple #pragma.
Length of Service String
Service String: The service string comes from the string specified in the SERVICE compiler option.
Signed offset of the end of the current CSECT
Signed offset of the end of current CSECT: A 32-bit field that contains the signed offset from PFD (Prefix Data) to the end of the current CSECT.
Signed offset of the debug data block
Signed offset of the debug data block : A 32-bit field that contains the signed offset from PFD to the debug data block.

Examples

Figure 2 and Figure 3 show how prefix data is generated from a sample program that is compiled with the RENT, SERVICE (Service String), and DEBUG (or -g) options.
Figure 2. A sample program to generate prefix data
   #pragma comment(copyright,"copyright comment")
   #pragma comment(user,"user comment")
   int main(){
     return 0;
   }
Figure 3. Prefix data generated
@@PFD@@  DC    XL8'00C300C300D50000'   Prefix Data Marker                000008
         DC    CL8'20160513'           Compiled Date YYYYMMDD            000008
         DC    CL6'152705'             Compiled Time HHMMSS              000008
         DC    XL4'42030000'           Compiler Version                  000008
         DC    XL2'0000'               Reserved                          000008
         DC    BL1'00000000'           Flag Set 1                        000008
         DC    BL1'00000000'           Flag Set 2                        000008
         DC    BL1'00000000'           Flag Set 3                        000008
         DC    BL1'11110000'           Flag Set 4                        000008     
         DC    XL4'00000000'                                             000008
         DS 0H                                                           000008
         DC AL2(30)                                                      000008
         DC C'copyright comment user comment'                            000008
         DS 0H                                                           000008
         DC AL2(14)                                                      000008
         DC C'Service String'                                            000008
         DC    A(@@END@@-@@PFD@@)                                        000008
         DC    A(@@DDB@@-@@PFD@@)                                        000008