Pass argc and argv to ldemul_choose_target.

Support -b64 in AIX
This commit is contained in:
Tom Rix 2001-12-03 23:15:28 +00:00
parent b61fdd7ef5
commit 742aeb63e9
10 changed files with 104 additions and 31 deletions

View file

@ -1,3 +1,18 @@
2001-12-02 Tom Rix <trix@redhat.com>
* configure.tgt : Remove eaixppc64 emulations.
* Makefile.in : Remove eaixppc64.c
* ldemul.c (ldemul_choose_target): New parameters argc, argv.
(ldemul_default_target): Same.
* emultempl/gld960.em (gld960_choose_target): Same.
* emultempl/gld960c.em (gld960_choose_target): Same.
* scripttempl/aix.sc: Remove OUTPUT_FORMAT.
* emultempl/aix.em (is_syscall): syscall_mask now a variable.
* emultempl/aix.em (gld*_read_file): symbol_mode_mask now a variable.
* emultempl/aix.em (gld*_parse_args): Handle -b32 -b64 emulation.
* emultempl/aix.em (choose_target): New function. Handle emulation of
-b32 and -b64.
2001-11-27 H.J. Lu <hjl@gnu.org>
* emulparams/elf_i386.sh (NO_SMALL_DATA): Set to yes.

View file

@ -380,7 +380,6 @@ ALL_64_EMULATIONS = \
emmo.o \
eelf64ppc.o \
eelf64lppc.o \
eaixppc64.o \
ehppa64linux.o
@ -1055,9 +1054,6 @@ stringify.sed: ${srcdir}/emultempl/$(STRINGIFY)
ea29k.c: $(srcdir)/emulparams/a29k.sh \
$(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/a29k.sc ${GEN_DEPENDS}
${GENSCRIPTS} a29k "$(tdir_a29k)"
eaixppc64.c: $(srcdir)/emulparams/aixppc64.sh \
$(srcdir)/emultempl/aix.em $(srcdir)/scripttempl/aix.sc ${GEN_DEPENDS}
${GENSCRIPTS} aixppc64 "$(tdir_aixppc64)"
eaixppc.c: $(srcdir)/emulparams/aixppc.sh \
$(srcdir)/emultempl/aix.em $(srcdir)/scripttempl/aix.sc ${GEN_DEPENDS}
${GENSCRIPTS} aixppc "$(tdir_aixppc)"

View file

@ -377,11 +377,7 @@ powerpc-*-netware*) targ_emul=ppcnw ;;
powerpcle-*-pe) targ_emul=ppcpe ;;
powerpcle-*-winnt*) targ_emul=ppcpe ;;
powerpcle-*-cygwin*) targ_emul=ppcpe ;;
powerpc-*-aix*) targ_emul=aixppc
targ_extra_emuls="aixppc64"
tdir_aixppc64=${targ_alias}
;;
powerpc-*-aix*) targ_emul=aixppc ;;
powerpc-*-beos*) targ_emul=aixppc ;;
rs6000-*-aix*) targ_emul=aixrs6 ;;
tic30-*-*aout*) targ_emul=tic30aout ;;

View file

@ -57,6 +57,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
static int gld${EMULATION_NAME}_parse_args PARAMS ((int, char **));
static void gld${EMULATION_NAME}_after_open PARAMS ((void));
static char * choose_target PARAMS ((int, char **));
static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
static void gld${EMULATION_NAME}_read_file PARAMS ((const char *, boolean));
static void gld${EMULATION_NAME}_free PARAMS ((PTR));
@ -114,6 +115,15 @@ static struct export_symbol_list *export_symbols;
/* Maintains the 32 or 64 bit mode state of import file */
static unsigned int symbol_mode = 0x04;
/* Which symbol modes are valid */
static unsigned int symbol_mode_mask = 0x0d;
/* Whether this is a 64 bit link */
static int is_64bit = 0;
/* Which syscalls from import file are valid */
static unsigned int syscall_mask = 0x77;
/* This routine is called before anything else is done. */
static void
@ -174,15 +184,12 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
OPTION_PD,
OPTION_PT,
OPTION_STRCMPCT,
OPTION_UNIX
OPTION_UNIX,
OPTION_32,
OPTION_64,
};
/*
b64 is an empty option. The native linker uses -b64 for xcoff64 support
Our linker uses -m aixppc64 for xcoff64 support. The choice for the
correct emulation is done in collect2.c via the environmental varible
LDEMULATION.
binitfini has special handling in the linker backend. The native linker
uses the arguemnts to generate a table of init and fini functions for
the executable. The important use for this option is to support aix 4.2+
@ -268,7 +275,8 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
{"bso", no_argument, NULL, OPTION_AUTOIMP},
{"bstrcmpct", no_argument, NULL, OPTION_STRCMPCT},
{"btextro", no_argument, &textro, 1},
{"b64", no_argument, NULL, 0},
{"b32", no_argument, NULL, OPTION_32},
{"b64", no_argument, NULL, OPTION_64},
{"static", no_argument, NULL, OPTION_NOAUTOIMP},
{"unix", no_argument, NULL, OPTION_UNIX},
{NULL, no_argument, NULL, 0}
@ -530,6 +538,19 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
case OPTION_UNIX:
unix_ld = true;
break;
case OPTION_32:
is_64bit = 0;
syscall_mask = 0x77;
symbol_mode_mask = 0x0d;
break;
case OPTION_64:
is_64bit = 1;
syscall_mask = 0xcc;
symbol_mode_mask = 0x0e;
break;
}
return 1;
@ -807,6 +828,42 @@ gld${EMULATION_NAME}_before_allocation ()
}
}
static char *
choose_target (argc, argv)
int argc;
char **argv;
{
int i, j, jmax;
static char *from_outside;
static char *from_inside;
static char *argv_to_target[][2] =
{
NULL, "aixcoff-rs6000",
"-b32", "aixcoff-rs6000",
"-b64", "aixcoff64-rs6000",
};
jmax = 3;
from_outside = getenv (TARGET_ENVIRON);
if (from_outside != (char *)NULL)
return from_outside;
/* Set to default. */
from_inside = argv_to_target[0][1];
for (i = 1; i < argc; i++)
{
for (j = 1; j < jmax; j++)
{
if (0 == strcmp (argv[i], argv_to_target[j][0]))
from_inside = argv_to_target[j][1];
}
}
return from_inside;
}
static int change_symbol_mode (char *input)
{
/*
@ -875,7 +932,7 @@ static int is_syscall(char *input, unsigned int *flag)
}
if (0 == strcmp(input, string)) {
if (1 << bit & ${SYSCALL_MASK}) {
if (1 << bit & syscall_mask) {
*flag = s[bit].flag;
return 1;
} else {
@ -1035,7 +1092,7 @@ gld${EMULATION_NAME}_read_file (filename, import)
continue;
}
if (symbol_mode & ${SYMBOL_MODE_MASK})
if (symbol_mode & symbol_mode_mask)
{
/* This is a symbol to be imported or exported. */
symname = s;
@ -1278,7 +1335,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
gld${EMULATION_NAME}_after_open,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,
choose_target,
gld${EMULATION_NAME}_before_allocation,
gld${EMULATION_NAME}_get_script,
"${EMULATION_NAME}",

View file

@ -40,7 +40,7 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307
#include "ldemul.h"
static void gld960_before_parse PARAMS ((void));
static char *gld960_choose_target PARAMS ((void));
static char *gld960_choose_target PARAMS ((int, char **));
static void gld960_set_output_arch PARAMS ((void));
static char *gld960_get_script PARAMS ((int *));
@ -90,7 +90,9 @@ gld960_set_output_arch()
}
static char *
gld960_choose_target()
gld960_choose_target (argc, argv)
int argc ATTRIBUTE_UNUSED;
char **argv ATTRIBUTE_UNUSED;
{
#ifdef GNU960

View file

@ -43,7 +43,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
static void gld960_before_parse PARAMS ((void));
static void gld960_set_output_arch PARAMS ((void));
static char *gld960_choose_target PARAMS ((void));
static char *gld960_choose_target PARAMS ((int, char **));
static char *gld960_get_script PARAMS ((int *));
#ifdef GNU960
@ -105,7 +105,9 @@ gld960_set_output_arch()
}
static char *
gld960_choose_target()
gld960_choose_target (argc, argv)
int argc ATTRIBUTE_UNUSED;
char **argv ATTRIBUTE_UNUSED;
{
#ifdef GNU960

View file

@ -169,15 +169,20 @@ ldemul_recognized_file (entry)
}
char *
ldemul_choose_target ()
ldemul_choose_target (argc, argv)
int argc;
char **argv;
{
return ld_emulation->choose_target ();
return ld_emulation->choose_target (argc, argv);
}
/* The default choose_target function. */
char *
ldemul_default_target ()
ldemul_default_target (argc, argv)
int argc ATTRIBUTE_UNUSED;
char **argv ATTRIBUTE_UNUSED;
{
char *from_outside = getenv (TARGET_ENVIRON);
if (from_outside != (char *) NULL)

View file

@ -25,7 +25,7 @@ extern void ldemul_after_open PARAMS ((void));
extern void ldemul_after_allocation PARAMS ((void));
extern void ldemul_before_allocation PARAMS ((void));
extern void ldemul_set_output_arch PARAMS ((void));
extern char *ldemul_choose_target PARAMS ((void));
extern char *ldemul_choose_target PARAMS ((int, char**));
extern void ldemul_choose_mode PARAMS ((char *));
extern void ldemul_list_emulations PARAMS ((FILE *));
extern void ldemul_list_emulation_options PARAMS ((FILE *));
@ -43,7 +43,7 @@ extern boolean ldemul_recognized_file
extern boolean ldemul_open_dynamic_archive
PARAMS ((const char *, struct search_dirs *,
struct lang_input_statement_struct *));
extern char *ldemul_default_target PARAMS ((void));
extern char *ldemul_default_target PARAMS ((int, char**));
extern void after_parse_default PARAMS ((void));
extern void after_open_default PARAMS ((void));
extern void after_allocation_default PARAMS ((void));
@ -78,7 +78,7 @@ typedef struct ld_emulation_xfer_struct {
void (*set_output_arch) PARAMS ((void));
/* Decide which target name to use. */
char * (*choose_target) PARAMS ((void));
char * (*choose_target) PARAMS ((int, char**));
/* Run before allocating output sections. */
void (*before_allocation) PARAMS ((void));

View file

@ -267,7 +267,7 @@ main (argc, argv)
emulation = get_emulation (argc, argv);
ldemul_choose_mode (emulation);
default_target = ldemul_choose_target ();
default_target = ldemul_choose_target (argc, argv);
lang_init ();
ldemul_before_parse ();
lang_has_input_file = false;

View file

@ -2,8 +2,8 @@
# AIX always uses shared libraries. The section VMA appears to be
# unimportant. The native linker aligns the sections on boundaries
# specified by the -H option.
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH})
${RELOCATING+${LIB_SEARCH_DIRS}}
ENTRY(__start)