This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Surprising result with ld -r



Given the attched files main.c, foo0.c, foo1.c
This is on x86_64-linux.

$ gcc -c foo0.c foo1.c main.c
$ gcc -o main1.pm foo0.o main.o
./main1.pm
foo0

However
$ gcc -o main1.pm foo0.o main.o -r -nostdlib
$ gcc -o main2.sm foo1.o main1.pm -Wl,-zmuldefs
./main2.sm
foo1

What is the rationale for -r not resolving "foo" in
$ gcc -o main1.pm foo0.o main.o -r -nostdlib
?

One would think that ld -r would resolve the global symbols it can resolve at each step, rather than waiting for the final link to resolve globals that are defined early.

--Douglas Rupp
AdaCore
#include <stdio.h>

void
foo ()
{
  printf ("foo0 called\n");
}
#include <stdio.h>
void
foo ()
{
  printf ("foo1 called\n");
}
extern void foo ();

void
main ()
{
   foo ();
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]