From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29513 invoked by alias); 19 Mar 2011 01:13:52 -0000 Received: (qmail 29502 invoked by uid 22791); 19 Mar 2011 01:13:51 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 19 Mar 2011 01:13:47 +0000 From: "zeev.tarantov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/48200] New: linking shared library with LTO results in different exported symbols X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zeev.tarantov at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sat, 19 Mar 2011 02:21:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg02079.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200 Summary: linking shared library with LTO results in different exported symbols Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassigned@gcc.gnu.org ReportedBy: zeev.tarantov@gmail.com The library is libpci.so.3.1.7, released 2010-01-31, part of every linux distro. Homepage is: http://mj.ucw.cz/pciutils.html, source repository is: http://www.kernel.org/git/?p=utils/pciutils/pciutils.git;a=shortlog Object files compiled with CFLAGS: "-O2 -fPIC -Wall -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -flto". If linked with: gcc -shared -Wl,-O1 -Wl,--as-needed -Wl,-soname,libpci.so.3 -Wl,--version-script=libpci.ver -o libpci.so.3.1.7 init.o access.o generic.o dump.o names.o filter.o names-hash.o names-parse.o names-net.o names-cache.o params.o caps.o sysfs.o proc.o i386-ports.o -lz -lresolv Then (as expected): objdump -T libpci.so.3.1.7 | grep pci_fill_info 00000000000032f0 g DF .text 000000000000006c (LIBPCI_3.0) pci_fill_info 00000000000032f0 g DF .text 000000000000006c LIBPCI_3.1 pci_fill_info But if linked with LTO: gcc -shared -Wl,-O1 -Wl,--as-needed -Wl,-flto -Wl,-soname,libpci.so.3 -Wl,--version-script=libpci.ver -o libpci.so.3.1.7 init.o access.o generic.o dump.o names.o filter.o names-hash.o names-parse.o names-net.o names-cache.o params.o caps.o sysfs.o proc.o i386-ports.o -lz -lresolv Then: objdump -T libpci.so.3.1.7 | grep pci_fill_info No such symbol. gcc (Gentoo SVN) 4.6.0-pre9999 20110318 (prerelease) rev. 171169 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. GNU ld (Linux/GNU Binutils) 2.21.51.0.7.20110306 Copyright 2011 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. I don't know enough to tell whether the problem is in pciutils, binutils or gcc. If this is invalid and I'm just spamming, I apologize. Please kindly point me in the right direction to fix this issue. Preproccessed source is (relevant parts): int pci_fill_info(struct pci_dev *, int flags) __attribute__((visibility("default"))); # 170 "pci.h" int pci_fill_info_v30(struct pci_dev *, int flags) __attribute__((visibility("default"))); int pci_fill_info_v31(struct pci_dev *, int flags) __attribute__((visibility("default"))); int pci_fill_info_v31(struct pci_dev *d, int flags) { if (flags & 0x10000) { flags &= ~0x10000; d->known_fields = 0; pci_free_caps(d); } if (flags & ~d->known_fields) d->known_fields |= d->methods->fill_info(d, flags & ~d->known_fields); return d->known_fields; } ; extern int pci_fill_info_v30(struct pci_dev *d, int flags) __attribute__((alias("pci_fill_info_v31"))); asm(".symver " "pci_fill_info_v30" "," "pci_fill_info@LIBPCI_3.0"); asm(".symver " "pci_fill_info_v31" "," "pci_fill_info@@LIBPCI_3.1");