Fix import symbols for AIX.

This commit is contained in:
Tom Rix 2001-09-06 15:20:01 +00:00
parent 7ccaa899b1
commit 1fdf02497c
9 changed files with 114 additions and 76 deletions

View File

@ -1,3 +1,14 @@
2001-09-05 Tom Rix <trix@redhat.com>
* xcofflink.c (bfd_xcoff_import_symbol): Handle import file XMC_XO
and syscall symbols.
(write_global_symbol) : Same.
(bfd_xcoff_export_symbol): Remove unused syscall param.
* libxcoff.h: Change prototype of bfd_xcoff_export symbol and
bfd_xcoff_import_symbol.
* bfd-in.h: Same.
* bfd-in2.h : Regenerate.
2001-09-04 Richard Henderson <rth@redhat.com> 2001-09-04 Richard Henderson <rth@redhat.com>
* elf64-alpha.c (SKIP_HOWTO): New. * elf64-alpha.c (SKIP_HOWTO): New.

View File

@ -722,10 +722,9 @@ extern boolean bfd_xcoff_link_record_set
bfd_size_type)); bfd_size_type));
extern boolean bfd_xcoff_import_symbol extern boolean bfd_xcoff_import_symbol
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
bfd_vma, const char *, const char *, const char *)); bfd_vma, const char *, const char *, const char *, unsigned int));
extern boolean bfd_xcoff_export_symbol extern boolean bfd_xcoff_export_symbol
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *));
boolean));
extern boolean bfd_xcoff_link_count_reloc extern boolean bfd_xcoff_link_count_reloc
PARAMS ((bfd *, struct bfd_link_info *, const char *)); PARAMS ((bfd *, struct bfd_link_info *, const char *));
extern boolean bfd_xcoff_record_link_assignment extern boolean bfd_xcoff_record_link_assignment

View File

@ -722,10 +722,9 @@ extern boolean bfd_xcoff_link_record_set
bfd_size_type)); bfd_size_type));
extern boolean bfd_xcoff_import_symbol extern boolean bfd_xcoff_import_symbol
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
bfd_vma, const char *, const char *, const char *)); bfd_vma, const char *, const char *, const char *, unsigned int));
extern boolean bfd_xcoff_export_symbol extern boolean bfd_xcoff_export_symbol
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *));
boolean));
extern boolean bfd_xcoff_link_count_reloc extern boolean bfd_xcoff_link_count_reloc
PARAMS ((bfd *, struct bfd_link_info *, const char *)); PARAMS ((bfd *, struct bfd_link_info *, const char *));
extern boolean bfd_xcoff_record_link_assignment extern boolean bfd_xcoff_record_link_assignment

View File

@ -248,10 +248,9 @@ extern boolean bfd_xcoff_link_record_set
bfd_size_type)); bfd_size_type));
extern boolean bfd_xcoff_import_symbol extern boolean bfd_xcoff_import_symbol
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
bfd_vma, const char *, const char *, const char *)); bfd_vma, const char *, const char *, const char *, unsigned int));
extern boolean bfd_xcoff_export_symbol extern boolean bfd_xcoff_export_symbol
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *));
boolean));
extern boolean bfd_xcoff_link_count_reloc extern boolean bfd_xcoff_link_count_reloc
PARAMS ((bfd *, struct bfd_link_info *, const char *)); PARAMS ((bfd *, struct bfd_link_info *, const char *));
extern boolean bfd_xcoff_record_link_assignment extern boolean bfd_xcoff_record_link_assignment

View File

@ -2514,7 +2514,7 @@ bfd_xcoff_link_record_set (output_bfd, info, harg, size)
boolean boolean
bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile, bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
impmember) impmember, syscall_flag)
bfd *output_bfd; bfd *output_bfd;
struct bfd_link_info *info; struct bfd_link_info *info;
struct bfd_link_hash_entry *harg; struct bfd_link_hash_entry *harg;
@ -2522,6 +2522,7 @@ bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
const char *imppath; const char *imppath;
const char *impfile; const char *impfile;
const char *impmember; const char *impmember;
unsigned int syscall_flag;
{ {
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg; struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
@ -2564,7 +2565,7 @@ bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
h = hds; h = hds;
} }
h->flags |= XCOFF_IMPORT; h->flags |= (XCOFF_IMPORT | syscall_flag);
if (val != (bfd_vma) -1) if (val != (bfd_vma) -1)
{ {
@ -2631,11 +2632,10 @@ bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
/* Export a symbol. */ /* Export a symbol. */
boolean boolean
bfd_xcoff_export_symbol (output_bfd, info, harg, syscall) bfd_xcoff_export_symbol (output_bfd, info, harg)
bfd *output_bfd; bfd *output_bfd;
struct bfd_link_info *info; struct bfd_link_info *info;
struct bfd_link_hash_entry *harg; struct bfd_link_hash_entry *harg;
boolean syscall ATTRIBUTE_UNUSED;
{ {
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg; struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
@ -5334,7 +5334,10 @@ xcoff_write_global_symbol (h, p)
if (((h->flags & XCOFF_DEF_REGULAR) == 0 && if (((h->flags & XCOFF_DEF_REGULAR) == 0 &&
(h->flags & XCOFF_DEF_DYNAMIC) != 0) || (h->flags & XCOFF_DEF_DYNAMIC) != 0) ||
(h->flags & XCOFF_IMPORT) != 0) { (h->flags & XCOFF_IMPORT) != 0) {
ldsym->l_smtype |= L_IMPORT; /* Clear l_smtype
Import symbols are defined so the check above will make the l_smtype
XTY_SD. But this is not correct, it should be cleared. */
ldsym->l_smtype = L_IMPORT;
} }
if (((h->flags & XCOFF_DEF_REGULAR) != 0 && if (((h->flags & XCOFF_DEF_REGULAR) != 0 &&
@ -5353,6 +5356,29 @@ xcoff_write_global_symbol (h, p)
ldsym->l_smclas = h->smclas; ldsym->l_smclas = h->smclas;
if (ldsym->l_smtype & L_IMPORT)
{
if ((h->root.type == bfd_link_hash_defined ||
h->root.type == bfd_link_hash_defweak) &&
(h->root.u.def.value != 0))
{
ldsym->l_smclas = XMC_XO;
}
else if ((h->flags & (XCOFF_SYSCALL32 | XCOFF_SYSCALL64)) ==
(XCOFF_SYSCALL32 | XCOFF_SYSCALL64))
{
ldsym->l_smclas = XMC_SV3264;
}
else if (h->flags & XCOFF_SYSCALL32)
{
ldsym->l_smclas = XMC_SV;
}
else if (h->flags & XCOFF_SYSCALL64)
{
ldsym->l_smclas = XMC_SV64;
}
}
if (ldsym->l_ifile == (bfd_size_type) -1) { if (ldsym->l_ifile == (bfd_size_type) -1) {
ldsym->l_ifile = 0; ldsym->l_ifile = 0;

View File

@ -1,3 +1,7 @@
2001-09-05 Tom Rix <trix@redhat.com>
* xcoff.h : Add XCOFF_SYSCALL32 and XCOFF_SYSCALL64 hash table flags.
2001-08-27 Andreas Jaeger <aj@suse.de> 2001-08-27 Andreas Jaeger <aj@suse.de>
* xcoff.h (struct __rtinit): Make proper prototype for rtl. * xcoff.h (struct __rtinit): Make proper prototype for rtl.

View File

@ -122,6 +122,8 @@
/* 14 ??? */ /* 14 ??? */
#define XMC_TC0 15 /* Read-write TOC anchor */ #define XMC_TC0 15 /* Read-write TOC anchor */
#define XMC_TD 16 /* Read-write data in TOC */ #define XMC_TD 16 /* Read-write data in TOC */
#define XMC_SV64 17 /* Read-only 64 bit supervisor call */
#define XMC_SV3264 18 /* Read-only 32 or 64 bit supervisor call */
/* The ldhdr structure. This appears at the start of the .loader /* The ldhdr structure. This appears at the start of the .loader
section. */ section. */
@ -305,6 +307,11 @@ struct xcoff_link_hash_entry
* XCOFF_RTINIT * XCOFF_RTINIT
* Symbol is the __rtinit symbol * Symbol is the __rtinit symbol
* *
* XCOFF_SYSCALL32
* Symbol is an imported 32 bit syscall
*
* XCOFF_SYSCALL64
* Symbol is an imported 64 bit syscall
*/ */
#define XCOFF_REF_REGULAR 0x00000001 #define XCOFF_REF_REGULAR 0x00000001
@ -322,7 +329,8 @@ struct xcoff_link_hash_entry
#define XCOFF_DESCRIPTOR 0x00001000 #define XCOFF_DESCRIPTOR 0x00001000
#define XCOFF_MULTIPLY_DEFINED 0x00002000 #define XCOFF_MULTIPLY_DEFINED 0x00002000
#define XCOFF_RTINIT 0x00004000 #define XCOFF_RTINIT 0x00004000
#define XCOFF_SYSCALL32 0x00008000
#define XCOFF_SYSCALL64 0x00010000
/* The XCOFF linker hash table. */ /* The XCOFF linker hash table. */

View File

@ -3,6 +3,10 @@
* ld.texinfo (Options, --stack): Correct default value for stack * ld.texinfo (Options, --stack): Correct default value for stack
reserve. reserve.
2001-09-05 Tom Rix <trix@redhat.com>
* emultempl/aix.em : Handle import file XMC_XO and syscall symbols.
2001-09-03 Andreas Jaeger <aj@suse.de> 2001-09-03 Andreas Jaeger <aj@suse.de>
* emultempl/beos.em: Declare prototypes for comparions functions, * emultempl/beos.em: Declare prototypes for comparions functions,

View File

@ -108,7 +108,6 @@ struct export_symbol_list
{ {
struct export_symbol_list *next; struct export_symbol_list *next;
const char *name; const char *name;
boolean syscall;
}; };
static struct export_symbol_list *export_symbols; static struct export_symbol_list *export_symbols;
@ -642,7 +641,7 @@ gld${EMULATION_NAME}_before_allocation ()
h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false); h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
if (h == NULL) if (h == NULL)
einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n"); einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h, el->syscall)) if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h))
einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n"); einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
} }
@ -842,8 +841,7 @@ static int change_symbol_mode (char *input)
return 0; return 0;
} }
static int is_syscall(char *input, unsigned int *flag)
static int is_syscall (char *input)
{ {
/* /*
* 1 : yes * 1 : yes
@ -852,45 +850,44 @@ static int is_syscall (char *input)
*/ */
unsigned int bit; unsigned int bit;
char *string; char *string;
char *syscall_string[] = { struct sc {
"svc", /* 0x01 */ char *syscall_string;
"svc32", /* 0x02 */ unsigned int flag;
"svc3264", /* 0x04 */ } s [] = {
"svc64", /* 0x08 */ { "svc" /* 0x01 */, XCOFF_SYSCALL32 },
"syscall", /* 0x10 */ { "svc32" /* 0x02 */, XCOFF_SYSCALL32 },
"syscall32", /* 0x20 */ { "svc3264" /* 0x04 */, XCOFF_SYSCALL32 | XCOFF_SYSCALL64 },
"syscall3264", /* 0x40 */ { "svc64" /* 0x08 */, XCOFF_SYSCALL64 },
"syscall64", /* 0x80 */ { "syscall" /* 0x10 */, XCOFF_SYSCALL32 },
NULL { "syscall32" /* 0x20 */, XCOFF_SYSCALL32 },
{ "syscall3264" /* 0x40 */, XCOFF_SYSCALL32 | XCOFF_SYSCALL64 },
{ "syscall64" /* 0x80 */, XCOFF_SYSCALL64 },
{ NULL, 0 },
}; };
for (bit = 0; ;bit++) *flag = 0;
{
string = syscall_string[bit]; for (bit = 0; ;bit++) {
if (NULL == string)
{ string = s[bit].syscall_string;
return -1; if (NULL == string) {
} return -1;
if (0 == strcmp (input, string))
{
if (1 << bit & ${SYSCALL_MASK})
{
return 1;
}
else
{
return 0;
}
}
} }
if (0 == strcmp(input, string)) {
if (1 << bit & ${SYSCALL_MASK}) {
*flag = s[bit].flag;
return 1;
} else {
return 0;
}
}
}
/* should not be here */ /* should not be here */
return -1; return -1;
} }
/* Read an import or export file. For an import file, this is called /* Read an import or export file. For an import file, this is called
by the before_allocation emulation routine. For an export file, by the before_allocation emulation routine. For an export file,
this is called by the parse_args emulation routine. */ this is called by the parse_args emulation routine. */
@ -939,7 +936,7 @@ gld${EMULATION_NAME}_read_file (filename, import)
{ {
char *s; char *s;
char *symname; char *symname;
boolean syscall; unsigned int syscall_flag = 0;
bfd_vma address; bfd_vma address;
struct bfd_link_hash_entry *h; struct bfd_link_hash_entry *h;
@ -1042,7 +1039,7 @@ gld${EMULATION_NAME}_read_file (filename, import)
{ {
/* This is a symbol to be imported or exported. */ /* This is a symbol to be imported or exported. */
symname = s; symname = s;
syscall = false; syscall_flag = 0;
address = (bfd_vma) -1; address = (bfd_vma) -1;
while (! isspace ((unsigned char) *s) && *s != '\0') while (! isspace ((unsigned char) *s) && *s != '\0')
@ -1074,29 +1071,21 @@ gld${EMULATION_NAME}_read_file (filename, import)
int status; int status;
char *end; char *end;
status = is_syscall (s); status = is_syscall(s, &syscall_flag);
if (0 > status) {
/* not a system call, check for address */
address = strtoul (s, &end, 0);
switch (status) /* not a system call, check for address */
{ address = strtoul (s, &end, 0);
case 1: if (*end != '\0')
/* this is a system call */ {
syscall = true; einfo ("%s:%d: warning: syntax error in import/export file\n",
break; filename, lineno);
case 0: }
/* ignore this system call */ }
break;
default:
/* not a system call, check for address */
address = strtoul (s, &end, 0);
if (*end != '\0')
{
einfo ("%s:%d: warning: syntax error in import/export file\n",
filename, lineno);
}
}
} }
} }
@ -1109,7 +1098,6 @@ gld${EMULATION_NAME}_read_file (filename, import)
xmalloc (sizeof (struct export_symbol_list))); xmalloc (sizeof (struct export_symbol_list)));
n->next = export_symbols; n->next = export_symbols;
n->name = xstrdup (symname); n->name = xstrdup (symname);
n->syscall = syscall;
export_symbols = n; export_symbols = n;
} }
else else
@ -1125,7 +1113,7 @@ gld${EMULATION_NAME}_read_file (filename, import)
{ {
if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h, if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
address, imppath, impfile, address, imppath, impfile,
impmember)) impmember, syscall_flag))
einfo ("%X%s:%d: failed to import symbol %s: %E\n", einfo ("%X%s:%d: failed to import symbol %s: %E\n",
filename, lineno, symname); filename, lineno, symname);
} }