[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] Re: [Gcl-devel] native relocation on Mac OS X
From: |
Aurelien Chanudet |
Subject: |
Re: [Axiom-developer] Re: [Gcl-devel] native relocation on Mac OS X |
Date: |
Mon, 8 Mar 2004 15:51:22 +0100 |
As far as MacOS X is concerned, I feel the need to say that the PLT
code is not compatible with the Mach-O object file format whatsoever.
In short, Mach-O does not have any procedure linkage table, although it
has a somewhat equivalent table which is called the indirect symbol
table. Nor does MacOS X uses GNU ld. Instead, MacOS X uses its own
linker which does not support the -Map switch.
In order to restore compatibility, I'd like to know if the PLT code can
now be considered as a final and stable solution for Linux platforms.
If this is so, I'll try to find as close a solution as possible
involving the PLT counterpart for Mach-O. I'll also have to add a
couple of Darwin specific gcc defined symbols to the table in o/plt.c.
I'll also have to undo some work I did in order to affect a value to
undefined symbols for Mach-O object files, given that we are now back
to undefined symbols with null values.
I'd be most grateful if someone could point me to the piece of code
which did change in the latest binutils. As far as I can tell, my
Mach-O relocation code continues to work when linking against external
symbols. See test code output below.
Aurelien
----
$ cat testbfd.c
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "bfd.h"
#include "bfdlink.h"
#define MY_BFD_BOOLEAN bfd_boolean
#define MY_BFD_FALSE FALSE
#define MY_BFD_TRUE TRUE
void error (char *format, ...)
{
va_list ap;
va_start (ap, format);
vfprintf (stderr, format, ap);
fprintf (stderr, "\n");
fflush (stderr);
va_end (ap);
exit (1);
}
int main (int argc, char **argv)
{
bfd *abfd;
char *filename;
asymbol **q;
long u, v;
if (argc != 2)
error ("bad arg count");
filename = argv[1];
if ((abfd = bfd_openr (filename, 0)) == NULL)
error ("bfd_openr failed");
if (!bfd_check_format (abfd, bfd_object))
error ("unrecognized format");
if ((u = bfd_get_symtab_upper_bound (abfd)) < 0)
error ("cannot get symtab upper bound");
if ((q = (asymbol **) alloca (u)) == NULL)
error ("cannot allocate wiggle room to store symtab");
if ((v = bfd_canonicalize_symtab (abfd, q)) == NULL)
error ("cannot retrieve symbols");
printf ("listing symbols:\n");
for (u=0 ; u < v ; u++)
{
if (q[u]->name == NULL) {
printf ("warning: symbol without name\n");
continue;
}
if (q[u]->section == NULL) {
printf ("warning: symbol %s has no section\n", q[u]->name);
continue;
}
printf ("%10lx - %s%s\n", q[u]->value + q[u]->section->vma,
q[u]->name, bfd_is_und_section (q[u]->section) ? "
(undefined)" : "");
}
bfd_close (abfd);
exit (0);
return 0;
}
$ cat testfile.c
extern int boo ();
extern int moo ();
int bar () { return 0; }
int foo ()
{
return bar () + boo () + moo ();
}
$ uname -a ; ./testbfd testfile.o
Darwin sabine.local 7.2.0 Darwin Kernel Version 7.2.0: Thu Dec 11
16:20:23 PST 2003; root:xnu/xnu-517.3.7.obj~1/RELEASE_PPC Power
Macintosh powerpc
listing symbols:
0 - _bar
20 - _foo
90 - _boo (undefined)
70 - _moo (undefined)
0 - dyld_stub_binding_helper (undefined)
$ uname -a ; ./testbfd testfile.o
Linux aljunied 2.4.18-newpmac #1 Thu Mar 14 22:44:49 EST 2002 ppc
unknown
listing symbols:
0 - testfile.c
0 -
0 -
0 -
0 - gcc2_compiled.
0 -
0 - bar
24 - foo
0 - boo (undefined)
0 - moo (undefined)