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: [email protected]
ReportedBy: [email protected]
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");