[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/21751] New: Gold: GC of C++ functions behaves differently than
From: |
jan.smets at nokia dot com |
Subject: |
[Bug gold/21751] New: Gold: GC of C++ functions behaves differently than LD.BFD with KEEP(*(.eh_frame)) |
Date: |
Tue, 11 Jul 2017 15:47:01 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=21751
Bug ID: 21751
Summary: Gold: GC of C++ functions behaves differently than
LD.BFD with KEEP(*(.eh_frame))
Product: binutils
Version: 2.29
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: gold
Assignee: ccoutant at gmail dot com
Reporter: jan.smets at nokia dot com
CC: ian at airs dot com
Target Milestone: ---
$ cat call.c main.c unused.cpp
void call(void)
{
// nothing
}
extern void call(void);
int main(void)
{
call();
return 0;
}
void unused(void)
{
// nothing
}
# build some "default" link script
# /opt/rh/devtoolset-6/root/usr/bin/ld --verbose > /tmp/link_script
# remove the header and footer, remove the SORT (otherwise gold won't accept
it)
# the only thing that is required in the link script is
# .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
/opt/rh/devtoolset-6/root/usr/bin/gcc -ffunction-sections -c call.c -o call.o
/opt/rh/devtoolset-6/root/usr/bin/gcc -ffunction-sections -c main.c -o main.o
/opt/rh/devtoolset-6/root/usr/bin/g++ -ffunction-sections -c unused.cpp -o
unused.o -fno-exceptions
LD=ld.gold
/opt/rh/devtoolset-6/root/usr/bin/$LD -r main.o call.o unused.o -o bla.a
echo "unused function is GC'ed"
/opt/rh/devtoolset-6/root/usr/bin/$LD --gc-sections --print-gc-sections bla.a
-o test.exe -e main
echo
/opt/rh/devtoolset-6/root/usr/bin/$LD --gc-sections --print-gc-sections main.o
call.o unused.o -o test.exe -e main
echo "unused function is *NOT* GC'ed"
/opt/rh/devtoolset-6/root/usr/bin/$LD --gc-sections --print-gc-sections bla.a
-o test.exe -T /tmp/link_script -e main
echo
/opt/rh/devtoolset-6/root/usr/bin/$LD --gc-sections --print-gc-sections main.o
call.o unused.o -o test.exe -T /tmp/link_script -e main
# ld.gold + link script (-T) where the script has
# .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
# ld.bfd behaves 'as expected'
unused.o has
Relocation section '.rela.eh_frame' at offset 0x1b8 contains 1 entries:
Offset Info Type Sym. Value Sym. Name +
Addend
000000000020 000500000002 R_X86_64_PC32 0000000000000000 .text._Z6unusedv
+ 0
Let's call it a feature as the script explicitly said to KEEP eh_frame and as a
result everything that eh_framer references. But it may not be what end users
expect. Plus, LD.BFD happily removed the 'unused' function.
--
You are receiving this mail because:
You are on the CC list for the bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug gold/21751] New: Gold: GC of C++ functions behaves differently than LD.BFD with KEEP(*(.eh_frame)),
jan.smets at nokia dot com <=