https://sourceware.org/bugzilla/show_bug.cgi?id=32846

--- Comment #6 from Michael Matz <matz at suse dot de> ---
At least I'm sure that first_hash usage was also brittle before.  Slightly
changing the situation of PR31482 (for which it was introduced) still shows
bugs related to LTO and archives, even without my patch.

Same input files like pr31482:

% cat pr31482a.c
#include <stdlib.h>

int
main()
{
  abort ();
  return 0;
}

% cat pr31482b.c
#include <stdlib.h>
#include <stdio.h>

void
abort (void)
{
  printf ("PASS\n");
  exit (0);
}

% cat pr31482c.c
#include <stdlib.h>
#include <stdio.h>

void
abort (void)
{
  printf ("PASS1\n");
  exit (0);
}

% cat test.sh
#!/bin/bash
set -x

rm -f shared.so static.a
gcc -flto -fpic -shared -o shared.so pr31482b.c
gcc -flto -fpic -c -o static.o pr31482c.c
ar rc static.a static.o
gcc -flto -fpic -Wl,--as-needed  shared.so pr31482a.c static.a -o wlto
gcc -fpic -Wl,--as-needed  shared.so pr31482a.c static.a -o nolto

Note specifically how the file requiring 'abort' now comes in the middle,
and hence the definition in shared.so should not be taken.  Neither should
the definition of libc.so be taken (that's the object of PR31482), but rather
the definition in static.a.  And hence 'PASS1' should be printed:

% ./nolto
PASS1
% ./wlto
Aborted (core dumped)

(This is with binutils at 464f5083, right before my patch, and very likely
reproduces with 2.44 as well).  So, whatever changes are to be done with the
first_hash handling, and its integration into the general linker symbol table,
also needs to take that into account, in addition to the kmod testcase.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to