bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/22756] Linker relaxation miscalculates symbol addresses on riscv


From: wilson at gcc dot gnu.org
Subject: [Bug ld/22756] Linker relaxation miscalculates symbol addresses on riscv
Date: Thu, 01 Mar 2018 01:00:59 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=22756

--- Comment #4 from Jim Wilson <wilson at gcc dot gnu.org> ---
I found another problem with linker relaxation and symbol sizes.

gamma05:2463$ cat tmp.c
extern void sub3 (void);

void __attribute__ ((noinline))
sub2 (void)
{
  sub3 ();
}

void __attribute__ ((noinline))
sub1 (void)
{
}

int
main (void)
{
  sub2 ();
  return 0;
}
gamma05:2464$ cat tmp2.c
void
sub3 (void)
{
}
gamma05:2465$ riscv32-unknown-linux-gnu-gcc -O2 tmp.c tmp2.c
gamma05:2466$ riscv32-unknown-linux-gnu-nm -S --size-sort a.out
00012018 00000001 b completed.5737
00010352 00000002 T __libc_csu_fini
000102f4 00000002 T sub2
000102f8 00000002 T sub3
00012010 00000004 G _IO_stdin_used
00010240 0000000e T main
00010250 00000026 T _start
000102fa 00000058 T __libc_csu_init
000102f6 fffffffc T sub1
gamma05:2467$ 

Sub1 has a size of (unsigned) -4 which can't be right.  The problem here is
that we update the symbol address first, and then we use the new address when
checking to see if the size should be updated also which is wrong.  The size
check needs to use the old address.  But since we can't have deleted relocs
spanning symbols, we can fix this by adding an "else".

Looking at all ports that handle both address and size updates after deleting
bytes, I see that only elf32-msp430.c handles this correctly.  And soon risc-v
will get it right also.  The other 7 appear to get this wrong.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]