Bug 13298 - ar --plugin doesn't work on mixed IR/non-IR input
Summary: ar --plugin doesn't work on mixed IR/non-IR input
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-14 18:39 UTC by H.J. Lu
Modified: 2020-10-28 21:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-10-14 18:39:56 UTC
[hjl@gnu-6 slim-1]$ cat main.c
extern int bar ();

int
main ()
{
  return bar ();
}
[hjl@gnu-6 slim-1]$ cat xxx.c
int
xxx ()
{
  return 0;
}
[hjl@gnu-6 slim-1]$ cat bar.c
extern int xxx ();

int bar (void)
{
  return xxx ();
}
[hjl@gnu-6 slim-1]$ make
/usr/gcc-4.7.0-x32/bin/gcc    -c -o main.o main.c
/usr/gcc-4.7.0-x32/bin/gcc -flto -c -o xxx.o xxx.c
/usr/gcc-4.7.0-x32/bin/gcc    -c -o bar.o bar.c
ld -r -o rel.o xxx.o bar.o
ar --plugin /usr/gcc-4.7.0-x32/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/liblto_plugin.so -rcsD lib.a rel.o
/usr/gcc-4.7.0-x32/bin/gcc -flto -o x main.o lib.a
main.o: In function `main':
main.c:(.text+0xa): undefined reference to `bar'
collect2: error: ld returned 1 exit status
make: *** [x] Error 1
[hjl@gnu-6 slim-1]$ 
..

Without --plugin, it works fine:

[hjl@gnu-6 slim-1]$ rm lib.a
[hjl@gnu-6 slim-1]$ make
ar -rcsD lib.a rel.o
/usr/gcc-4.7.0-x32/bin/gcc -flto -o x main.o lib.a
[hjl@gnu-6 slim-1]$
Comment 1 H.J. Lu 2011-10-14 19:00:30 UTC
The problem is ar/nm doesn't see symbols in .gnu_object_only section.
Comment 2 H.J. Lu 2011-10-14 19:02:56 UTC
AR ignores the normal symbol table.