binutils-gdb/ld/testsuite
Senthil Kumar Selvaraj b660e9eb7a Fix PR21404 - assertion fail when calculating symbol size
Fix a host of problems related to adjustment of
symbol values and sizes when relaxing for avr.

1. Adjust symbol size first before adjusting symbol
value. Otherwise, a symbol whose value just got adjusted to the
relaxed address also ends up getting resized. See pr21404-1.s.

2. Reduce symbol sizes only if their span is below an
alignment boundary. Otherwise, the size gets decremented once when the
actual instruction is relaxed and padding bytes are added, and again
when the padding bytes are deleted (if padding ends up being unnecessary).
pr21404-2.s addresses that, and this bug is really the root cause of PR21404.

3. Adjust all symbol values before an alignment boundary.
Previous code did not adjust symbol values if they fell in the
would-be padded area, resulting in incorrect symbol values in some
cases (see pr21404-3.s).

4. Increase symbol sizes if alignment directives require so.
As pr21404-4.s shows
.global nonzero_sym
L1:
    jmp  L1
nonzero_sym:
    nop
    nop
    .p2align 2
.size nonzero_sym, .-nonzero_sym

The two nops satisfy the 4 byte alignment at assembly time and
therefore the size of nonzero_sym is 4. Relaxation shortens
the 4 byte jmp to a 2 byte rjmp, and to satisfy 4 byte alignment
the code places 2 extra padding bytes after the nops, increasing
nonzero_sym's size by 2. This wasn't handled before.

If the assembly code does not have any align directives, then the
boundary is the section size, and symbol values and sizes == boundary
should also get adjusted. To handle that case, add a did_pad variable
and use that to determine whether it should use < boundary or <= boundary.

Also get rid of reloc_toaddr, which is now redundant.  toaddr is now not
adjusted to handle the above case - the newly added
did_pad variable does the job.

pr21404-{5,6,7,8} are the same testcases written for local symbols, as
the code handles them slightly differently.
2017-05-04 10:34:29 +05:30
..
config x86: Add run-time tests for -mtls-dialect=gnu2 2017-04-28 12:42:18 -07:00
ld-aarch64 Rename R_AARCH64_TLSDESC_LD64_LO12_NC to R_AARCH64_TLSDESC_LD64_LO12 and R_AARCH64_TLSDESC_ADD_LO12_NC to R_AARCH64_TLSDESC_ADD_LO12. 2017-03-13 09:58:04 +00:00
ld-alpha Align eh_frame FDEs according to their encoding 2017-03-05 14:49:54 +10:30
ld-arc [ARC] Add new linker emulation for nps 2017-01-10 10:55:13 +00:00
ld-arm Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-auto-import Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-avr Fix PR21404 - assertion fail when calculating symbol size 2017-05-04 10:34:29 +05:30
ld-bootstrap Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-cdtest Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-checks ld-checks: tweak overflow checks. 2017-03-15 10:23:19 +01:00
ld-cris Fix for PR ld/16044: elf32-cris.c h->plt.refcount inconsistency 2017-03-28 23:43:09 +02:00
ld-crx Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-cygwin Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-d10v Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-discard Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-elf Adjust testsuite/ld-elf/pr21384.d 2017-05-03 07:43:50 -07:00
ld-elfcomm Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-elfvers Add -rpath-link to various tests 2017-01-03 12:36:02 +10:30
ld-elfvsb Clean elfvsb files left over from previous runs 2017-04-10 15:10:58 +09:30
ld-elfweak Add -rpath-link to various tests 2017-01-03 12:36:02 +10:30
ld-fastcall Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-frv Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-gc Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-h8300 Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-i386 x86: Add -Wl,--no-as-needed to some TLS tests 2017-05-02 16:01:39 -07:00
ld-ia64 Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-ifunc ELF: Add run-time tests for -z now 2017-04-28 12:35:18 -07:00
ld-libs Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-linkonce Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-m68hc11 Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-m68k Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-mep Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-metag Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-mips-elf MIPS16/GAS: Relax 32-bit non-PIC PC-relative synthetic instructions 2017-05-03 20:47:40 +01:00
ld-misc Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-mmix Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-mn10300 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-nds32 Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-nios2 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-pe pe/coff: handle weak defined symbol for gc-sections. 2017-04-07 10:03:17 +02:00
ld-pie Don't run C tests in ld testsuite unless we have a C compiler 2017-01-03 11:47:47 +10:30
ld-plugin Handle symbol defined in IR and referenced in DSO 2017-04-20 07:48:35 -07:00
ld-powerpc PowerPC addpcis fix 2017-02-28 11:59:47 +10:30
ld-pru PRU LD Port 2016-12-31 12:04:11 +10:30
ld-s390 Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-scripts Testsuite fixes for hppa64-hpux 2017-02-25 19:13:34 +10:30
ld-selective Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-sh Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-shared Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-size Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-sparc ld: fix regressions with rett instructions in sparc tests. 2017-04-24 05:31:31 -07:00
ld-spu Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-srec Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-tic6x Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-tilegx Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-tilepro Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-undefined Implement -z dynamic-undefined-weak 2017-04-19 20:39:52 +09:30
ld-unique [ld, testsuite] Append $board_cflags in one more place in ld-unique/unique.exp 2017-02-01 12:57:25 +00:00
ld-v850 Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-vax-elf Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-versados Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-visium Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-vxworks Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-x86-64 x86: Add -Wl,--no-as-needed to some TLS tests 2017-05-02 16:01:39 -07:00
ld-xc16x Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-xstormy16 Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ld-xtensa Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-z8k Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
lib x86: Run GNU2 TLS tests with working GNU2 TLS support 2017-05-01 11:02:55 -07:00
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013 New Year - binutils ChangeLog rotation 2014-01-08 05:32:12 -08:00
ChangeLog-2014 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
ChangeLog-2015 binutils ChangeLog rotation 2016-01-01 22:59:17 +10:30
ChangeLog-9303