On 2025-11-03 21:26, Siddhesh Poyarekar wrote:
On i686, offsets into object archives could be 64-bit, but they're inconsistently treated across the lto, which may sometimes result in truncation of those offsets for large archives.Use int64_t/off_t consistently across all uses of archive offsets to make sure that they're always read and mapped correctly. gcc/lto/ChangeLog PR lto/122515 * lto.h (lto_section_slot): Set type of START to off_t. * lto-common.cc (lto_read_section_data): Adjust. * lto-object.cc (lto_obj_file_open): Set type of OFFSET to int64_t. gcc/ChangeLog PR lto/122515 * lto-wrapper.cc (debug_objcopy): Set type of INOFF to int64_t. (run_gcc): Set type of FILE_OFFSET to int64_t. gcc/testsuite/ChangeLog PR lto/122515 * lib/lto.exp (lto-build-archive): New procedure. (lto-execute-1): Use it. (lto-link-and-maybe-run, lto-get-options-main): Handle ar-link. * gcc.dg/lto/pr122515_0.c: New test case. * gcc.dg/lto/pr122515_1.c: New file. * gcc.dg/lto/pr122515_2.c: Likewise. * gcc.dg/lto/pr122515_3.c: Likewise. * gcc.dg/lto/pr122515_4.c: Likewise. * gcc.dg/lto/pr122515_5.c: Likewise. * gcc.dg/lto/pr122515_6.c: Likewise. * gcc.dg/lto/pr122515_7.c: Likewise. * gcc.dg/lto/pr122515_8.c: Likewise. * gcc.dg/lto/pr122515_9.c: Likewise. Signed-off-by: Siddhesh Poyarekar <[email protected]> --- Testing notes: - Built and tested in an i686 mock root, where the issue is reproducible - Built and tested config=i686, no new regressions - Bootstrapped on x86_64 in progress - Bootstrap config=ubsan in progress (not needed for this, but my harness does it anyway)
I forgot to mention, I'd like to backport this all the way to gcc14 if it's OK.
Thanks, Sid
