From owner-freebsd-bugs@FreeBSD.ORG Mon Aug 7 17:00:35 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 90F2816A4DF for ; Mon, 7 Aug 2006 17:00:35 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 391A243D58 for ; Mon, 7 Aug 2006 17:00:34 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k77H0XQS058415 for ; Mon, 7 Aug 2006 17:00:33 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k77H0XYN058414; Mon, 7 Aug 2006 17:00:33 GMT (envelope-from gnats) Resent-Date: Mon, 7 Aug 2006 17:00:33 GMT Resent-Message-Id: <200608071700.k77H0XYN058414@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Nelson Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E691716A4DA for ; Mon, 7 Aug 2006 16:59:17 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7AAE443D46 for ; Mon, 7 Aug 2006 16:59:17 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.6/8.13.6) id k77GxGTA014220; Mon, 7 Aug 2006 11:59:16 -0500 (CDT) (envelope-from dan) Message-Id: <200608071659.k77GxGTA014220@dan.emsphone.com> Date: Mon, 7 Aug 2006 11:59:16 -0500 (CDT) From: Dan Nelson To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/101590: -O2 optimizing out abi-tag note from executables X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2006 17:00:35 -0000 >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@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: