binutils-gdb/ld/testsuite
Tamar Christina 74edb473c9 PE/Windows x86_64: Fix weak undef symbols after image base change
The change in PR19011 changed the image load address from being in the lower
32-bit address space to the higher 64-bit address space.

However when you have a weak undef symbol which stays undef at the end of
linking the linker has to resolve this (Windows loader does not support undef
symbols).  As such typically these would resolve to 0.

The relocation used for these weak symbols are the normal 32-bit PC_REL call
relocs.  So when doing the overflow check LD checks if the distance between the
symbol and the call is within range.  However now that the load address is
> 32-bits and the symbol val is 0 this overflow check will always fail.

As such the linker gives a bogus error.  This patch makes the linker not emit
the overflow failure but chooses to still let the check be performed (as it's
mid-end code).

One down side of this is that it does break the common convention that the call
be to sym at 0x0. i.e. before you'd get

      401015:   74 05                   je     40101c
      401017:   e8 e4 ef bf ff          callq  0

and now you get

   140001015:   74 05                   je     14000101c
   140001017:   e8 e4 ef ff bf          call   100000000

since the call is PC_REL there's no way to get the range large enough to
resolve to 0.  As such I have chosen to leave it as the furthest simple range
that we can still represent.

By only ignoring the error we leave the symbol value itself to still be 0
such that the if(<symbol>) checks still work correctly.

bfd/ChangeLog:

2021-04-01  Tamar Christina  <tamar.christina@arm.com>

	PR ld/26659
	* cofflink.c (_bfd_coff_generic_relocate_section): Ignore overflow.

ld/ChangeLog:

2021-04-01  Tamar Christina  <tamar.christina@arm.com>

	PR ld/26659
	* testsuite/ld-pe/pe.exp: Add test.
	* testsuite/ld-pe/pr26659-weak-undef-sym.d: New test.
	* testsuite/ld-pe/pr26659-weak-undef-sym.s: New test.
2021-04-01 17:54:04 +01:00
..
config ld: tests: add -msim when testing bfin targets 2021-01-14 01:09:48 -05:00
ld-aarch64 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-alpha Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-arc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-arm Remove arm-symbianelf 2021-02-09 23:36:16 +10:30
ld-auto-import Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-avr Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-bootstrap PR27226, ld.bfd contains huge .rodata section 2021-01-26 20:54:43 +10:30
ld-bpf Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-cdtest ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-checks ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-cris Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-crx Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-csky CSKY: Change default linker script for elf toolchain. 2020-10-26 17:13:21 +08:00
ld-ctf ld: do not rely on the exact size of the CTF symtypetabs in test results 2021-03-25 16:32:53 +00:00
ld-cygwin Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-d10v Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-discard Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-dynamic Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-elf Remove bfd_stdint.h 2021-03-31 10:49:23 +10:30
ld-elfcomm ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-elfvers ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-elfvsb ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-elfweak ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-fastcall Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-frv Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-gc PE image base fallout 2021-03-12 10:41:34 +10:30
ld-h8300 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-i386 elf: Handle .gnu.debuglto_.debug_* sections 2021-03-18 20:57:02 -07:00
ld-ia64 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-ifunc ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-libs Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-linkonce Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-m68hc11 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-m68k Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-mep Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-metag Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-mips-elf ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-misc ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-mmix Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-mn10300 ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-msp430-elf Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-nds32 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-nios2
ld-or1k Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-pdp11 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-pe PE/Windows x86_64: Fix weak undef symbols after image base change 2021-04-01 17:54:04 +01:00
ld-pie Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-plugin Add PR27441 testcase 2021-02-26 17:49:04 +10:30
ld-powerpc aix: implement TLS relocation for gas and ld 2021-03-12 22:47:33 +10:30
ld-pru
ld-riscv-elf RISC-V: Improve multiple relax passes problem. 2021-03-11 17:27:13 +08:00
ld-s12z Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-s390 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-scripts PE image base fallout 2021-03-12 10:41:34 +10:30
ld-selective ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-sh ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-shared ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-size Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-sparc sparc-sun-solaris2 and sparc64-sun-solaris2 config 2021-01-06 21:03:55 +10:30
ld-spu Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-srec PE image base fallout 2021-03-12 10:41:34 +10:30
ld-tic6x ld testsuite: change unresolved to unsupported/fail 2021-02-14 22:34:27 +10:30
ld-tilegx Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-tilepro Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-undefined bfd: don't silently wrap or truncate PE image section RVAs 2021-03-09 08:52:32 +01:00
ld-unique Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-v850 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-vax-elf Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-visium Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-vxworks Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-x86-64 x86-64: Add a testcase for PR ld/27590 2021-03-19 17:23:47 -07:00
ld-xc16x Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-xstormy16 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-xtensa PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
ld-z8k Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-z80 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
lib PE image base fallout 2021-03-12 10:41:34 +10:30
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-9303