binutils-gdb/include/coff
Oleg Tolmatcev d9d09c878e PE/COFF: raise normal PE section limit safely
PE/COFF stores symbol section numbers in a 16-bit field.  Binutils used
signed 16-bit handling there, which limited normal PE objects to 32767
sections even though MSVC and Clang already accept a larger unsigned
range.

Raise the normal PE section limit to 65279, while keeping the PE/COFF
special section-number values for undefined, absolute and debug symbols
working correctly.  Do this by decoding and encoding normal PE symbol
section numbers as unsigned values in the ordinary range, but preserving
the reserved PE constants explicitly.

Also add a gas test that exercises a normal PE object above the old
32767-section limit and checks that objdump reports the high section
number correctly.

bfd/ChangeLog:

	* coffcode.h (COFF_DEFAULT_MAX_NSCNS): Define.
	(bfd_coff_std_swap_table): Use it for the default maximum section
	count.
	(ticoff0_swap_table): Likewise.
	(ticoff1_swap_table): Likewise.
	* peXXigen.c (pe_decode_sym_section_number): New function.
	(pe_encode_sym_section_number): New function.
	(_bfd_XXi_swap_sym_in): Use pe_decode_sym_section_number.
	(_bfd_XXi_swap_sym_out): Use pe_encode_sym_section_number.

include/ChangeLog:

	* coff/pe.h (IMAGE_SYM_UNDEFINED): Define.
	(IMAGE_SYM_ABSOLUTE): Define.
	(IMAGE_SYM_DEBUG): Define.
	(IMAGE_SYM_SECTION_MAX): Define.

gas/ChangeLog:

	* testsuite/gas/pe/pe.exp: Run large-obj-normal.
	* testsuite/gas/pe/large-obj-normal.s: New test.
	* testsuite/gas/pe/large-obj-normal.d: New test.

Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
2026-07-17 15:39:11 +02:00
..
aarch64.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
alpha.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
arm.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
ChangeLog-0415 binutils ChangeLog rotation 2016-01-01 22:59:17 +10:30
ChangeLog-9103 Add copyright notices 2012-12-10 12:48:03 +00:00
ecoff.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
external.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
i386.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
ia64.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
internal.h prune BeOS leftovers 2026-07-17 15:37:56 +02:00
loongarch64.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
mcore.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
mips.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
msdos.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
pe.h PE/COFF: raise normal PE section limit safely 2026-07-17 15:39:11 +02:00
riscv64.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
rs6k64.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
rs6000.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
sh.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
sym.h PR27116, Spelling errors found by Debian style checker 2021-01-01 14:36:35 +10:30
symconst.h
ti.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
tic4x.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
tic30.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
tic54x.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
x86.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
x86_64.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
xcoff.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
z8k.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
z80.h Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30