COFF: Difference between revisions

505 bytes added ,  1 year ago
→‎String Table: Mention alternate section name encoding
[unchecked revision][unchecked revision]
(→‎External Links: Add link to official Microsoft COFF spec)
(→‎String Table: Mention alternate section name encoding)
Line 328:
===String Table===
 
The String tableTable contains string names for any sections or symbols that are longer than eight characters.
 
The String tableTable immediately follows the Symbol tableTable, and can be located by using the following formula:
<pre>
String Table Offset = File Header.f_symptr + File Header.f_nsyms * sizeof( Symbol Table Entry )
Line 336:
</pre>
 
The first four bytes of the stringString tableTable are an integer indicating the overall size in bytes of the string table. Each of the strings in the table are null terminated.
 
The Section tableTable name field and the Symbol tableTable name field are actaullyactually more complicated than was detailed above, they in fact look more like this:
<source lang="c">
{
Line 353:
</source>
 
If the name is eight characters or fewer, then the field "zeroes" will be non-zero, and "name" should be interprettedinterpreted as a character array. Note that this field is not null-terminated unless it is fewer than eight characters in length.
 
If the name is more than eight characters, the "zeroes" field (the first four bytes of "name") will be zero. In this case the "offset" field should be used as an offset value into the String table to locate the Symbol or Section name.
 
NOTE: Some tools (like GCC) use a different format for the section name field. Instead of the first four bytes being zero and the last four being an offset into the string table (as described just above), the first byte is a `/`, and the rest are the decimal digits of the offset within the string table where the section name may be found. For example, a section named ".name_thats_too_long" will have "/4" stored in its section name field, assuming this is the first string stored in the string table.
 
==Example==
Anonymous user