This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: patch, ldemul_choose_target, AIX -b64 support
Tom Rix wrote:
> Alan Modra wrote:
>
> >If you find a spare moment, please take a look at bringing aix.em into
> compliance >with the GNU coding standards.
>
> Will do tonight or tomorrow..
Here it is.
I addition the formatting changes, there are some other cleanups.
This has been partially checked, builds native Aix 4.3.3 and x86 linux x
Aix and x86 linux x macos. No regressions in the ld tests but that isn't
saying much..
It is in the queue to be execised by gcc. Once this is done, I will
check it in maybe later tonight.
--
Tom Rix
GCC Engineer
trix@redhat.com
2001-12-04 Tom Rix <trix@redhat.com>
* emultempl/aix.em (choose_target): Change default target to
OUTPUT_FORMAT for ppcmacos. Add braces to remove compiler
warning.
(gld*_read_file): Fix typo.
(change_symbol_mode): Add prototype.
(is_syscall): Same.
* emulparams/aixppc.sh (SYSCALL_MASK, SYMBOL_MODE_MASK): Delete.
* emulparams/aixrs6.sh : Same.
* emulparams/ppcmacos.sh : Same.
* emulparams/aixppc64.sh : Delete file.
* emultempl/aix.em : Formatting changes.
2001-12-04 Alan Modra <amodra@bigpond.net.au>
* ldexp.c (exp_print_token): Correct "table" entry for RSHIFT.
diff -rc ld-old/emulparams/aixppc.sh ld/emulparams/aixppc.sh
*** ld-old/emulparams/aixppc.sh Mon Dec 3 22:54:35 2001
--- ld/emulparams/aixppc.sh Mon Dec 3 23:57:13 2001
***************
*** 2,6 ****
SCRIPT_NAME=aix
OUTPUT_FORMAT="aixcoff-rs6000"
ARCH=powerpc
! SYSCALL_MASK=0x77
! SYMBOL_MODE_MASK=0x0d
--- 2,5 ----
SCRIPT_NAME=aix
OUTPUT_FORMAT="aixcoff-rs6000"
ARCH=powerpc
!
diff -rc ld-old/emulparams/aixrs6.sh ld/emulparams/aixrs6.sh
*** ld-old/emulparams/aixrs6.sh Mon Dec 3 22:54:35 2001
--- ld/emulparams/aixrs6.sh Mon Dec 3 23:57:43 2001
***************
*** 2,6 ****
SCRIPT_NAME=aix
OUTPUT_FORMAT="aixcoff-rs6000"
ARCH=rs6000
! SYSCALL_MASK=0x77
! SYMBOL_MODE_MASK=0x0d
--- 2,5 ----
SCRIPT_NAME=aix
OUTPUT_FORMAT="aixcoff-rs6000"
ARCH=rs6000
!
diff -rc ld-old/emulparams/ppcmacos.sh ld/emulparams/ppcmacos.sh
*** ld-old/emulparams/ppcmacos.sh Mon Dec 3 22:54:35 2001
--- ld/emulparams/ppcmacos.sh Mon Dec 3 23:59:50 2001
***************
*** 2,6 ****
SCRIPT_NAME=aix
OUTPUT_FORMAT="xcoff-powermac"
ARCH=powerpc
- SYSCALL_MASK=0x77
- SYMBOL_MODE_MASK=0x0d
--- 2,4 ----
diff -rc ld-old/emultempl/aix.em ld/emultempl/aix.em
*** ld-old/emultempl/aix.em Mon Dec 3 22:54:36 2001
--- ld/emultempl/aix.em Tue Dec 4 09:15:34 2001
***************
*** 57,72 ****
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));
! static void gld${EMULATION_NAME}_find_relocs
! PARAMS ((lang_statement_union_type *));
static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *));
static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
static boolean gld${EMULATION_NAME}_unrecognized_file
PARAMS ((lang_input_statement_type *));
/* The file alignment required for each section. */
static unsigned long file_align;
--- 57,74 ----
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));
! static void gld${EMULATION_NAME}_find_relocs
! PARAMS ((lang_statement_union_type *));
static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *));
static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
static boolean gld${EMULATION_NAME}_unrecognized_file
PARAMS ((lang_input_statement_type *));
+ static int is_syscall PARAMS ((char *, unsigned int *));
+ static int change_symbol_mode PARAMS ((char *));
/* The file alignment required for each section. */
static unsigned long file_align;
***************
*** 167,173 ****
bfd_signed_vma val;
char *end;
! enum {
OPTION_IGNORE = 300,
OPTION_AUTOIMP,
OPTION_ERNOTOK,
--- 169,176 ----
bfd_signed_vma val;
char *end;
! enum
! {
OPTION_IGNORE = 300,
OPTION_AUTOIMP,
OPTION_ERNOTOK,
***************
*** 296,304 ****
changing it to = lets us treat it as a getopt option. */
indx = optind;
if (indx == 0)
! {
! indx = 1;
! }
if (indx < argc && strncmp (argv[indx], "-b", 2) == 0)
{
--- 299,305 ----
changing it to = lets us treat it as a getopt option. */
indx = optind;
if (indx == 0)
! indx = 1;
if (indx < argc && strncmp (argv[indx], "-b", 2) == 0)
{
***************
*** 344,351 ****
case 'H':
val = strtoul (optarg, &end, 0);
! if (*end != '\0'
! || (val & (val - 1)) != 0)
einfo ("%P: warning: ignoring invalid -H number %s\n", optarg);
else
file_align = val;
--- 345,351 ----
case 'H':
val = strtoul (optarg, &end, 0);
! if (*end != '\0' || (val & (val - 1)) != 0)
einfo ("%P: warning: ignoring invalid -H number %s\n", optarg);
else
file_align = val;
***************
*** 399,407 ****
*t++ = 0;
if (0 != strlen (i))
! {
! link_info.init_function = i;
! }
f = t;
while (*t && ':' != *t)
--- 399,405 ----
*t++ = 0;
if (0 != strlen (i))
! link_info.init_function = i;
f = t;
while (*t && ':' != *t)
***************
*** 409,420 ****
*t = 0;
if (0 != strlen (f))
! {
! link_info.fini_function = f;
! }
}
! break;
!
case OPTION_AUTOIMP:
link_info.static_link = false;
break;
--- 407,416 ----
*t = 0;
if (0 != strlen (f))
! link_info.fini_function = f;
}
! break;
!
case OPTION_AUTOIMP:
link_info.static_link = false;
break;
***************
*** 461,467 ****
case OPTION_MAXSTACK:
val = strtoull (optarg, &end, 0);
if (*end != '\0')
! einfo ("%P: warning: ignoring invalid -bmaxstack number %s\n", optarg);
else
maxstack = val;
break;
--- 457,464 ----
case OPTION_MAXSTACK:
val = strtoull (optarg, &end, 0);
if (*end != '\0')
! einfo ("%P: warning: ignoring invalid -bmaxstack number %s\n",
! optarg);
else
maxstack = val;
break;
***************
*** 505,511 ****
exp_intop (0xfff)));
t = exp_binop ('&',
exp_binop ('+', t, exp_intop (31)),
! exp_intop (~ (bfd_vma) 31));
lang_section_start (".data", t);
}
break;
--- 502,508 ----
exp_intop (0xfff)));
t = exp_binop ('&',
exp_binop ('+', t, exp_intop (31)),
! exp_intop (~(bfd_vma) 31));
lang_section_start (".data", t);
}
break;
***************
*** 526,532 ****
exp_nameop (SIZEOF_HEADERS, NULL));
t = exp_binop ('&',
exp_binop ('+', t, exp_intop (31)),
! exp_intop (~ (bfd_vma) 31));
lang_section_start (".text", t);
}
break;
--- 523,529 ----
exp_nameop (SIZEOF_HEADERS, NULL));
t = exp_binop ('&',
exp_binop ('+', t, exp_intop (31)),
! exp_intop (~(bfd_vma) 31));
lang_section_start (".text", t);
}
break;
***************
*** 621,628 ****
bfd_size_type size;
/* If the symbol is defined, we may have been invoked from
! collect, and the sets may already have been built, so we do
! not do anything. */
if (p->h->type == bfd_link_hash_defined
|| p->h->type == bfd_link_hash_defweak)
continue;
--- 618,625 ----
bfd_size_type size;
/* If the symbol is defined, we may have been invoked from
! collect, and the sets may already have been built, so we do
! not do anything. */
if (p->h->type == bfd_link_hash_defined
|| p->h->type == bfd_link_hash_defweak)
continue;
***************
*** 634,640 ****
}
size = (p->count + 2) * 4;
! if (! bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size))
einfo ("%F%P: bfd_xcoff_link_record_set failed: %E\n");
}
}
--- 631,637 ----
}
size = (p->count + 2) * 4;
! if (!bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size))
einfo ("%F%P: bfd_xcoff_link_record_set failed: %E\n");
}
}
***************
*** 661,667 ****
h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
if (h == NULL)
einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
! if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h))
einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
}
--- 658,664 ----
h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
if (h == NULL)
einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
! if (!bfd_xcoff_export_symbol (output_bfd, &link_info, h))
einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
}
***************
*** 699,712 ****
}
/* Let the XCOFF backend set up the .loader section. */
! if (! bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath,
! entry_symbol, file_align,
! maxstack, maxdata,
! gc && ! unix_ld ? true : false,
! modtype,
! textro ? true : false,
! unix_ld,
! special_sections))
einfo ("%P%F: failed to set dynamic section sizes: %E\n");
/* Look through the special sections, and put them in the right
--- 696,708 ----
}
/* Let the XCOFF backend set up the .loader section. */
! if (!bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath,
! entry_symbol, file_align,
! maxstack, maxdata,
! gc && !unix_ld ? true : false,
! modtype,
! textro ? true : false,
! unix_ld, special_sections))
einfo ("%P%F: failed to set dynamic section sizes: %E\n");
/* Look through the special sections, and put them in the right
***************
*** 725,745 ****
continue;
/* Remove this section from the list of the output section.
! This assumes we know what the script looks like. */
is = NULL;
os = lang_output_section_find (sec->output_section->name);
! if (os == NULL) {
einfo ("%P%F: can't find output section %s\n",
sec->output_section->name);
- }
for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->header.next)
{
!
! if ((*pls)->header.type == lang_input_section_enum &&
! (*pls)->input_section.section == sec)
{
! is = (lang_input_section_type *) *pls;
*pls = (*pls)->header.next;
break;
}
--- 721,739 ----
continue;
/* Remove this section from the list of the output section.
! This assumes we know what the script looks like. */
is = NULL;
os = lang_output_section_find (sec->output_section->name);
! if (os == NULL)
einfo ("%P%F: can't find output section %s\n",
sec->output_section->name);
for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->header.next)
{
! if ((*pls)->header.type == lang_input_section_enum
! && (*pls)->input_section.section == sec)
{
! is = (lang_input_section_type *) * pls;
*pls = (*pls)->header.next;
break;
}
***************
*** 749,763 ****
lang_statement_union_type **pwls;
for (pwls = &(*pls)->wild_statement.children.head;
! *pwls != NULL;
! pwls = &(*pwls)->header.next)
{
! if ((*pwls)->header.type == lang_input_section_enum &&
! (*pwls)->input_section.section == sec)
{
!
! is = (lang_input_section_type *) *pwls;
*pwls = (*pwls)->header.next;
break;
}
--- 743,755 ----
lang_statement_union_type **pwls;
for (pwls = &(*pls)->wild_statement.children.head;
! *pwls != NULL; pwls = &(*pwls)->header.next)
{
! if ((*pwls)->header.type == lang_input_section_enum
! && (*pwls)->input_section.section == sec)
{
! is = (lang_input_section_type *) * pwls;
*pwls = (*pwls)->header.next;
break;
}
***************
*** 778,784 ****
switch (i)
{
! default: /* to avoid warnings */
case XCOFF_SPECIAL_SECTION_TEXT:
/* _text */
oname = ".text";
--- 770,776 ----
switch (i)
{
! default: /* to avoid warnings */
case XCOFF_SPECIAL_SECTION_TEXT:
/* _text */
oname = ".text";
***************
*** 836,852 ****
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. */
--- 828,843 ----
int i, j, jmax;
static char *from_outside;
static char *from_inside;
! static char *argv_to_target[][2] = {
! {NULL, "${OUTPUT_FORMAT}"},
! {"-b32", "aixcoff-rs6000"},
! {"-b64", "aixcoff64-rs6000"},
! };
jmax = 3;
from_outside = getenv (TARGET_ENVIRON);
! if (from_outside != (char *) NULL)
return from_outside;
/* Set to default. */
***************
*** 859,890 ****
from_inside = argv_to_target[j][1];
}
}
!
return from_inside;
}
!
! static int change_symbol_mode (char *input)
{
- /*
- * 1 : state changed
- * 0 : no change
- */
-
char *symbol_mode_string[] = {
! "# 32", /* 0x01 */
! "# 64", /* 0x02 */
! "# no32", /* 0x04 */
! "# no64", /* 0x08 */
NULL,
};
unsigned int bit;
char *string;
! for (bit = 0; ; bit++)
{
string = symbol_mode_string[bit];
! if (NULL == string)
return 0;
if (0 == strcmp (input, string))
--- 850,881 ----
from_inside = argv_to_target[j][1];
}
}
!
return from_inside;
}
! /* Returns
! 1 : state changed
! 0 : no change */
! static int
! change_symbol_mode (input)
! char *input;
{
char *symbol_mode_string[] = {
! "# 32", /* 0x01 */
! "# 64", /* 0x02 */
! "# no32", /* 0x04 */
! "# no64", /* 0x08 */
NULL,
};
+
unsigned int bit;
char *string;
! for (bit = 0;; bit++)
{
string = symbol_mode_string[bit];
! if (string == NULL)
return 0;
if (0 == strcmp (input, string))
***************
*** 897,909 ****
return 0;
}
! static int is_syscall(char *input, unsigned int *flag)
{
- /*
- * 1 : yes
- * 0 : ignore
- * -1 : error, try something else
- */
unsigned int bit;
char *string;
--- 888,902 ----
return 0;
}
! /* Returns
! 1 : yes
! 0 : ignore
! -1 : error, try something else */
! static int
! is_syscall (input, flag)
! char *input;
! unsigned int *flag;
{
unsigned int bit;
char *string;
***************
*** 924,945 ****
*flag = 0;
! for (bit = 0; ;bit++) {
!
! string = s[bit].syscall_string;
! if (NULL == string) {
! return -1;
! }
! if (0 == strcmp(input, string)) {
! if (1 << bit & syscall_mask) {
! *flag = s[bit].flag;
! return 1;
! } else {
! return 0;
! }
}
- }
/* should not be here */
return -1;
}
--- 917,941 ----
*flag = 0;
! for (bit = 0;; bit++)
! {
! string = s[bit].syscall_string;
! if (string == NULL)
! return -1;
! if (0 == strcmp (input, string))
! {
! if (1 << bit & syscall_mask)
! {
! *flag = s[bit].flag;
! return 1;
! }
! else
! {
! return 0;
! }
! }
}
/* should not be here */
return -1;
}
***************
*** 1012,1018 ****
|| *s == '*'
|| change_symbol_mode (s)
|| (*s == '#' && s[1] == ' ')
! || (! import && *s == '#' && s[1] == '!'))
{
obstack_free (o, obstack_base (o));
continue;
--- 1008,1014 ----
|| *s == '*'
|| change_symbol_mode (s)
|| (*s == '#' && s[1] == ' ')
! || (!import && *s == '#' && s[1] == '!'))
{
obstack_free (o, obstack_base (o));
continue;
***************
*** 1042,1049 ****
keep = true;
imppath = s;
file = NULL;
! while (! ISSPACE (*s)
! && *s != '(' && *s != '\0')
{
if (*s == '/')
file = s + 1;
--- 1038,1044 ----
keep = true;
imppath = s;
file = NULL;
! while (!ISSPACE (*s) && *s != '(' && *s != '\0')
{
if (*s == '/')
file = s + 1;
***************
*** 1099,1105 ****
syscall_flag = 0;
address = (bfd_vma) -1;
! while (! ISSPACE (*s) && *s != '\0')
++s;
if (*s != '\0')
{
--- 1094,1100 ----
syscall_flag = 0;
address = (bfd_vma) -1;
! while (!ISSPACE (*s) && *s != '\0')
++s;
if (*s != '\0')
{
***************
*** 1111,1117 ****
++s;
se = s;
! while (! ISSPACE (*se) && *se != '\0')
++se;
if (*se != '\0')
{
--- 1106,1112 ----
++s;
se = s;
! while (!ISSPACE (*se) && *se != '\0')
++se;
if (*se != '\0')
{
***************
*** 1128,1152 ****
int status;
char *end;
! status = is_syscall(s, &syscall_flag);
! if (0 > status) {
! /* not a system call, check for address */
! address = strtoul (s, &end, 0);
!
! /* 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);
!
! }
! }
}
}
! if (! import)
{
struct export_symbol_list *n;
--- 1123,1145 ----
int status;
char *end;
! status = is_syscall (s, &syscall_flag);
! if (0 > status)
! {
! /* 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);
!
! }
! }
}
}
! if (!import)
{
struct export_symbol_list *n;
***************
*** 1168,1176 ****
}
else
{
! if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
! address, imppath, impfile,
! impmember, syscall_flag))
einfo ("%X%s:%d: failed to import symbol %s: %E\n",
filename, lineno, symname);
}
--- 1161,1169 ----
}
else
{
! if (!bfd_xcoff_import_symbol (output_bfd, &link_info, h,
! address, imppath, impfile,
! impmember, syscall_flag))
einfo ("%X%s:%d: failed to import symbol %s: %E\n",
filename, lineno, symname);
}
***************
*** 1186,1192 ****
obstack_free (o, obstack_base (o));
}
! if (! keep)
{
obstack_free (o, NULL);
free (o);
--- 1179,1185 ----
obstack_free (o, obstack_base (o));
}
! if (!keep)
{
obstack_free (o, NULL);
free (o);
***************
*** 1217,1223 ****
rs = &s->reloc_statement;
if (rs->name == NULL)
einfo ("%F%P: only relocations against symbols are permitted\n");
! if (! bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name))
einfo ("%F%P: bfd_xcoff_link_count_reloc failed: %E\n");
}
--- 1210,1216 ----
rs = &s->reloc_statement;
if (rs->name == NULL)
einfo ("%F%P: only relocations against symbols are permitted\n");
! if (!bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name))
einfo ("%F%P: bfd_xcoff_link_count_reloc failed: %E\n");
}
***************
*** 1244,1251 ****
case etree_assign:
if (strcmp (exp->assign.dst, ".") != 0)
{
! if (! bfd_xcoff_record_link_assignment (output_bfd, &link_info,
! exp->assign.dst))
einfo ("%P%F: failed to record assignment to %s: %E\n",
exp->assign.dst);
}
--- 1237,1244 ----
case etree_assign:
if (strcmp (exp->assign.dst, ".") != 0)
{
! if (!bfd_xcoff_record_link_assignment (output_bfd, &link_info,
! exp->assign.dst))
einfo ("%P%F: failed to record assignment to %s: %E\n",
exp->assign.dst);
}
***************
*** 1326,1333 ****
cat >>e${EMULATION_NAME}.c <<EOF
! struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
! {
gld${EMULATION_NAME}_before_parse,
syslib_default,
hll_default,
--- 1319,1325 ----
cat >>e${EMULATION_NAME}.c <<EOF
! struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = {
gld${EMULATION_NAME}_before_parse,
syslib_default,
hll_default,
***************
*** 1340,1354 ****
gld${EMULATION_NAME}_get_script,
"${EMULATION_NAME}",
"${OUTPUT_FORMAT}",
! 0, /* finish */
! 0, /* create_output_section_statements */
! 0, /* open_dynamic_archive */
! 0, /* place_orphan */
! 0, /* set_symbols */
gld${EMULATION_NAME}_parse_args,
gld${EMULATION_NAME}_unrecognized_file,
! NULL, /* list_options */
! NULL, /* recognized_file */
! NULL, /* find potential_libraries */
};
EOF
--- 1332,1346 ----
gld${EMULATION_NAME}_get_script,
"${EMULATION_NAME}",
"${OUTPUT_FORMAT}",
! 0, /* finish */
! 0, /* create_output_section_statements */
! 0, /* open_dynamic_archive */
! 0, /* place_orphan */
! 0, /* set_symbols */
gld${EMULATION_NAME}_parse_args,
gld${EMULATION_NAME}_unrecognized_file,
! NULL, /* list_options */
! NULL, /* recognized_file */
! NULL, /* find potential_libraries */
};
EOF
- References:
- patch, ldemul_choose_target, AIX -b64 support
- Re: patch, ldemul_choose_target, AIX -b64 support
- Re: patch, ldemul_choose_target, AIX -b64 support
- Re: patch, ldemul_choose_target, AIX -b64 support
- Re: patch, ldemul_choose_target, AIX -b64 support