bin/101590: -O2 optimizing out abi-tag note from executables
Dan Nelson
dnelson at allantgroup.com
Mon Aug 7 17:00:35 UTC 2006
>Number: 101590
>Category: bin
>Synopsis: -O2 optimizing out abi-tag note from executables
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Aug 07 17:00:33 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Dan Nelson
>Release: FreeBSD 6.1-STABLE i386
>Organization:
The Allant Group
>Environment:
System: FreeBSD dan.emsphone.com 6.1-STABLE FreeBSD 6.1-STABLE #0: Sun Aug 6 16:39:49 CDT 2006 zsh at dan.emsphone.com:/usr/obj/usr/src-6/sys/DANSMP i386
>Description:
gcc's -O2 level removes unreferenced static variables from object
files, which results in the 'abitag' symbol in lib/csu/common/crtbrand.c
being optimized out of existence from /usr/lib/crt1.o .
>How-To-Repeat:
Compile any program on a FreeBSD 6.0 or newer system (the default
CFLAGS was switched from -O to -O2 here), and note that the 'file'
command doesn't list the version of FreeBSD it was compiled on.
$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), dynamically linked (uses shared libs), stripped
After patching and reinstalling crt1.o, and relinking ls:
$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for FreeBSD 6.1 (601103), dynamically linked (uses shared libs), stripped
>Fix:
Mark abitag as __used instead of __unused, which will force gcc to
leave the symbol in the resulting object file even though it's static
and has no references.
Index: crtbrand.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/common/crtbrand.c,v
retrieving revision 1.4
diff -u -p -r1.4 crtbrand.c
--- crtbrand.c 17 Oct 2003 15:43:13 -0000 1.4
+++ crtbrand.c 7 Aug 2006 01:14:35 -0000
@@ -43,7 +43,7 @@ static const struct {
int32_t type;
char name[sizeof ABI_VENDOR];
int32_t desc;
-} abitag __attribute__ ((section (ABI_SECTION), aligned(4))) __unused = {
+} abitag __attribute__ ((section (ABI_SECTION), aligned(4))) __used = {
sizeof ABI_VENDOR,
sizeof(int32_t),
ABI_NOTETYPE,
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list