On 11/6/25 12:14 AM, Peter Damianov wrote:
This patch adds support for the BigObj COFF object file format to libiberty's
simple-object-coff.c. BigObj extends regular COFF to support a 32-bit section
count.

BigObj differs from COFF in a few ways:

* A different header structure
* 32-bit section counts instead of 16-bit
* 32-bit symbol section numbers instead of 16-bit
* 20-byte symbols instead of 18-byte symbols
   (due to the extended section numbers)

For a more detailed summary, read my blog post on this subject:
https://peter0x44.github.io/posts/bigobj_format_explained/

libiberty/ChangeLog:

        PR target/122472
        * simple-object-coff.c (struct external_filehdr_bigobj): New
        structure for BigObj file header.
        (bigobj_magic): New constant for BigObj magic bytes.
        (struct external_syment_bigobj): New structure for BigObj
        20-byte symbol table entries.
        (union external_auxent_bigobj): New union for BigObj 20-byte
        auxiliary symbol entries.
        (struct simple_object_coff_read): Add is_bigobj flag and make
        nscns 32-bit to support both formats.
        (struct simple_object_coff_attributes): Add is_bigobj flag.
        (simple_object_coff_match): Add BigObj format detection.
        (simple_object_coff_read_strtab): Use format-specific symbol
        size when calculating string table offset.
        (simple_object_coff_attributes_merge): Check is_bigobj flag.
        (simple_object_coff_write_filehdr_bigobj): New function.
        (simple_object_coff_write_to_file): Add logic for writing
        BigObj vs regular COFF format with appropriate symbol
        and auxiliary entry structures.

Signed-off-by: Peter Damianov <[email protected]>
---
v2: add PR target/122472 to ChangeLog to meet the expected format

  libiberty/simple-object-coff.c | 459 +++++++++++++++++++++++++++------
  1 file changed, 379 insertions(+), 80 deletions(-)


Pushed to master branch, thanks.

Reply via email to