0
SECTION HEADER #5
   .text name
       0 physical address
       0 virtual address
      24 size of raw data
    1B78 file pointer to raw data (00001B78 to 00001B9B)
    1B9C file pointer to relocation table
       0 file pointer to line numbers
       2 number of relocations
       0 number of line numbers
60101020 flags
         Code
         COMDAT; sym= __setdefaultprecision
         1 byte align
         Execute Read

I've looked into the documentation of COFF and couldn't understand how I get the symbol of the section (__setdefaultprecision), I have the pointer to the symbol table , string table, and array of sections, but how can I know the symbol of each section? Any help appreciated.

Neet33
  • 241
  • 1
  • 5
  • 17

1 Answers1

0

For COMDAT sections the first two entries in the symbol table with the section number of the COMDAT section provide the section's name and COMDAT symbol. The first symbol gives the name of the section, which in your example would be .text. The second entry provides the COMDAT symbol, named __setdefaultprecision in your example.

From the Microsoft Portable Executable and Common Object File Format Specification, revision 8.3:

COMDAT Sections (Object Only)

The first symbol that has the section value of the COMDAT section must be the section symbol. [...] The second symbol is called “the COMDAT symbol” and is used by the linker in conjunction with the Selection field.

If you use DUMPBIN /SYMBOLS on the .OBJ you were examining you should see two entries something like the following:

00A 00000000 SECT5  notype       Static       | .text
    Section length    C, #relocs    1, #linenums    0, checksum A2F45556, selection    2 (pick any)
...
00E 00000000 SECT5  notype ()    External     | __setdefaultprecision

Note that they won't necessarily be consecutive, but they'll be the first two SECT5 symbols in the table.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112