From 8d10083c23b9415a6d645b44d136104fcf8ed176 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 17 Jan 2024 07:46:37 -0800 Subject: ld: Put all emulation options in ldlex.h For each command line option, parse_args() calls ldemul_parse_args() to check if the command line option is an emulation option. But when there is a conflict between the emulation option value and the default option value, the default command line option will be processed as if the emulation option is used. Remove PARSE_AND_LIST_PROLOGUE and move all emulation options to ldlex.h to avoid conflicts. PR ld/31247 * ldlex.h (option_values): Add all emulation options. * emulparams/elf32mcore.sh (PARSE_AND_LIST_PROLOGUE): Removed. * emulparams/plt_unwind.sh (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/aarch64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/alphaelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/armelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/avrelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/bfin.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/cskyelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/hppaelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/ia64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/m68hc1xelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/m68kelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/metagelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/mipself.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/nds32elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/nto.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/ppc32elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/ppc64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/riscvelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/rxelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/s390.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/scoreelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/spuelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/tic6xdsbt.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/vxworks.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/aix.em: Include "ldlex.h". (OPTION_XXX): Removed. (gld${EMULATION_NAME}_read_file): Replace lineno with linenumber. * emultempl/beos.em (OPTION_XXX): Removed. * emultempl/elf.em: Include "ldlex.h". Don't check PARSE_AND_LIST_PROLOGUE. (OPTION_XXX): Removed. * emultempl/msp430.em: Include "ldlex.h". (OPTION_XXX): Removed. * emultempl/pe.em (OPTION_XXX): Removed. * emultempl/pep.em (OPTION_XXX): Likewise. * emultempl/ticoff.em: Include "ldlex.h". (OPTION_XXX): Removed. * emultempl/vms.em: Include "ldlex.h". (OPTION_XXX): Removed. * emultempl/xtensaelf.em (elf32xtensa_size_opt, elf32xtensa_no_literal_movement, elf32xtensa_abi): Moved out of PARSE_AND_LIST_PROLOGUE. (PARSE_AND_LIST_PROLOGUE): Removed. --- ld/emulparams/elf32mcore.sh | 4 - ld/emulparams/plt_unwind.sh | 5 - ld/emultempl/aarch64elf.em | 10 -- ld/emultempl/aix.em | 50 ++------ ld/emultempl/alphaelf.em | 6 - ld/emultempl/armelf.em | 25 ---- ld/emultempl/avrelf.em | 9 -- ld/emultempl/beos.em | 16 --- ld/emultempl/bfin.em | 5 - ld/emultempl/cskyelf.em | 6 - ld/emultempl/elf.em | 22 +--- ld/emultempl/hppaelf.em | 5 - ld/emultempl/ia64elf.em | 4 - ld/emultempl/m68hc1xelf.em | 5 - ld/emultempl/m68kelf.em | 4 - ld/emultempl/metagelf.em | 4 - ld/emultempl/mipself.em | 12 -- ld/emultempl/msp430.em | 5 +- ld/emultempl/nds32elf.em | 12 -- ld/emultempl/nto.em | 8 -- ld/emultempl/pe.em | 78 ------------ ld/emultempl/pep.em | 73 ----------- ld/emultempl/ppc32elf.em | 20 ---- ld/emultempl/ppc64elf.em | 35 ------ ld/emultempl/riscvelf.em | 10 -- ld/emultempl/rxelf.em | 7 -- ld/emultempl/s390.em | 4 - ld/emultempl/scoreelf.em | 1 - ld/emultempl/spuelf.em | 24 ---- ld/emultempl/tic6xdsbt.em | 6 - ld/emultempl/ticoff.em | 2 +- ld/emultempl/vms.em | 2 +- ld/emultempl/vxworks.em | 6 - ld/emultempl/xtensaelf.em | 14 +-- ld/ldlex.h | 286 ++++++++++++++++++++++++++++++++++++++++++++ 35 files changed, 304 insertions(+), 481 deletions(-) (limited to 'ld') diff --git a/ld/emulparams/elf32mcore.sh b/ld/emulparams/elf32mcore.sh index 88a8cb6..7d433fc 100644 --- a/ld/emulparams/elf32mcore.sh +++ b/ld/emulparams/elf32mcore.sh @@ -30,10 +30,6 @@ TEMPLATE_NAME=elf # This code gets inserted into the generic elf32.sc linker script # and allows us to define our own command line switches. -PARSE_AND_LIST_PROLOGUE=' -#define OPTION_BASE_FILE 300 -' - PARSE_AND_LIST_LONGOPTS=' {"base-file", required_argument, NULL, OPTION_BASE_FILE}, ' diff --git a/ld/emulparams/plt_unwind.sh b/ld/emulparams/plt_unwind.sh index ab16156..beb6726 100644 --- a/ld/emulparams/plt_unwind.sh +++ b/ld/emulparams/plt_unwind.sh @@ -1,10 +1,5 @@ PLT_UNWIND=yes -PARSE_AND_LIST_PROLOGUE=' -#define OPTION_LD_GENERATED_UNWIND_INFO 301 -#define OPTION_NO_LD_GENERATED_UNWIND_INFO 302 -' - PARSE_AND_LIST_LONGOPTS=' {"ld-generated-unwind-info", no_argument, NULL, OPTION_LD_GENERATED_UNWIND_INFO}, diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em index b647909..aa2859d 100644 --- a/ld/emultempl/aarch64elf.em +++ b/ld/emultempl/aarch64elf.em @@ -355,16 +355,6 @@ EOF # Define some shell vars to insert bits of code into the standard elf # parse_args and list_options functions. # -PARSE_AND_LIST_PROLOGUE=' -#define OPTION_NO_ENUM_SIZE_WARNING 309 -#define OPTION_PIC_VENEER 310 -#define OPTION_STUBGROUP_SIZE 311 -#define OPTION_NO_WCHAR_SIZE_WARNING 312 -#define OPTION_FIX_ERRATUM_835769 313 -#define OPTION_FIX_ERRATUM_843419 314 -#define OPTION_NO_APPLY_DYNAMIC_RELOCS 315 -' - PARSE_AND_LIST_SHORTOPTS=p PARSE_AND_LIST_LONGOPTS=' diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em index a445c32..33857b5 100644 --- a/ld/emultempl/aix.em +++ b/ld/emultempl/aix.em @@ -48,6 +48,7 @@ fragment < @@ -171,35 +172,6 @@ gld${EMULATION_NAME}_before_parse (void) /* Handle AIX specific options. */ -enum - { - OPTION_IGNORE = 300, - OPTION_AUTOIMP, - OPTION_ERNOTOK, - OPTION_EROK, - OPTION_EXPALL, - OPTION_EXPFULL, - OPTION_EXPORT, - OPTION_IMPORT, - OPTION_INITFINI, - OPTION_LOADMAP, - OPTION_MAXDATA, - OPTION_MAXSTACK, - OPTION_MODTYPE, - OPTION_NOAUTOIMP, - OPTION_NOEXPALL, - OPTION_NOEXPFULL, - OPTION_NOSTRCMPCT, - OPTION_PD, - OPTION_PT, - OPTION_STRCMPCT, - OPTION_UNIX, - OPTION_32, - OPTION_64, - OPTION_LIBPATH, - OPTION_NOLIBPATH, - }; - static void gld${EMULATION_NAME}_add_options (int ns, char **shortopts, int nl, struct option **longopts, @@ -1299,7 +1271,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) { struct obstack *o; FILE *f; - int lineno; + int linenumber; int c; bool keep; const char *imppath; @@ -1323,7 +1295,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) impfile = NULL; impmember = NULL; - lineno = 0; + linenumber = 0; /* Default to 32 and 64 bit mode symbols at top of /lib/syscalls.exp do not have a mode modifier and they @@ -1347,7 +1319,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) } obstack_1grow (o, '\0'); - ++lineno; + ++linenumber; s = (char *) obstack_base (o); while (ISSPACE (*s)) @@ -1377,7 +1349,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) else if (*s == '(') einfo (_("%F%P:%s:%d: #! ([member]) is not supported " "in import files\n"), - filename, lineno); + filename, linenumber); else { char cs; @@ -1403,7 +1375,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) impmember = ""; if (cs != '\0') einfo (_("%P:%s:%d: warning: syntax error in import file\n"), - filename, lineno); + filename, linenumber); } else { @@ -1415,7 +1387,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) *s = '\0'; else einfo (_("%P:%s:%d: warning: syntax error in import file\n"), - filename, lineno); + filename, linenumber); } } @@ -1451,7 +1423,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) if (*se != '\0') einfo (_("%P:%s%d: warning: syntax error in " "import/export file\n"), - filename, lineno); + filename, linenumber); } if (s != se) @@ -1469,7 +1441,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) { einfo (_("%P:%s:%d: warning: syntax error in " "import/export file\n"), - filename, lineno); + filename, linenumber); } } @@ -1503,7 +1475,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) address, imppath, impfile, impmember, syscall_flag)) einfo (_("%X%P:%s:%d: failed to import symbol %s: %E\n"), - filename, lineno, symname); + filename, linenumber, symname); } } } @@ -1513,7 +1485,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bool import) if (obstack_object_size (o) > 0) { einfo (_("%P:%s:%d: warning: ignoring unterminated last line\n"), - filename, lineno); + filename, linenumber); obstack_free (o, obstack_base (o)); } diff --git a/ld/emultempl/alphaelf.em b/ld/emultempl/alphaelf.em index cf32cd4..0445e79 100644 --- a/ld/emultempl/alphaelf.em +++ b/ld/emultempl/alphaelf.em @@ -111,12 +111,6 @@ EOF # Define some shell vars to insert bits of code into the standard elf # parse_args and list_options functions. # -PARSE_AND_LIST_PROLOGUE=' -#define OPTION_TASO 300 -#define OPTION_SECUREPLT (OPTION_TASO + 1) -#define OPTION_NO_SECUREPLT (OPTION_SECUREPLT + 1) -' - PARSE_AND_LIST_LONGOPTS=' { "taso", no_argument, NULL, OPTION_TASO }, { "secureplt", no_argument, NULL, OPTION_SECUREPLT }, diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em index 7fb1826..8f501ae 100644 --- a/ld/emultempl/armelf.em +++ b/ld/emultempl/armelf.em @@ -566,31 +566,6 @@ EOF # Define some shell vars to insert bits of code into the standard elf # parse_args and list_options functions. # -PARSE_AND_LIST_PROLOGUE=' -#define OPTION_THUMB_ENTRY 301 -#define OPTION_BE8 302 -#define OPTION_TARGET1_REL 303 -#define OPTION_TARGET1_ABS 304 -#define OPTION_TARGET2 305 -#define OPTION_FIX_V4BX 306 -#define OPTION_USE_BLX 307 -#define OPTION_VFP11_DENORM_FIX 308 -#define OPTION_NO_ENUM_SIZE_WARNING 309 -#define OPTION_PIC_VENEER 310 -#define OPTION_FIX_V4BX_INTERWORKING 311 -#define OPTION_STUBGROUP_SIZE 312 -#define OPTION_NO_WCHAR_SIZE_WARNING 313 -#define OPTION_FIX_CORTEX_A8 314 -#define OPTION_NO_FIX_CORTEX_A8 315 -#define OPTION_NO_MERGE_EXIDX_ENTRIES 316 -#define OPTION_FIX_ARM1176 317 -#define OPTION_NO_FIX_ARM1176 318 -#define OPTION_LONG_PLT 319 -#define OPTION_STM32L4XX_FIX 320 -#define OPTION_CMSE_IMPLIB 321 -#define OPTION_IN_IMPLIB 322 -' - PARSE_AND_LIST_SHORTOPTS=p PARSE_AND_LIST_LONGOPTS=' diff --git a/ld/emultempl/avrelf.em b/ld/emultempl/avrelf.em index 3fe8100..792be72 100644 --- a/ld/emultempl/avrelf.em +++ b/ld/emultempl/avrelf.em @@ -232,15 +232,6 @@ avr_finish (void) EOF -PARSE_AND_LIST_PROLOGUE=' - -#define OPTION_NO_CALL_RET_REPLACEMENT 301 -#define OPTION_PMEM_WRAP_AROUND 302 -#define OPTION_NO_STUBS 303 -#define OPTION_DEBUG_STUBS 304 -#define OPTION_DEBUG_RELAX 305 -' - PARSE_AND_LIST_LONGOPTS=' { "no-call-ret-replacement", no_argument, NULL, OPTION_NO_CALL_RET_REPLACEMENT}, diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em index 844d498..29c386c 100644 --- a/ld/emultempl/beos.em +++ b/ld/emultempl/beos.em @@ -70,22 +70,6 @@ gld${EMULATION_NAME}_before_parse (void) /* PE format extra command line options. */ -/* Used for setting flags in the PE header. */ -#define OPTION_BASE_FILE (300 + 1) -#define OPTION_DLL (OPTION_BASE_FILE + 1) -#define OPTION_FILE_ALIGNMENT (OPTION_DLL + 1) -#define OPTION_IMAGE_BASE (OPTION_FILE_ALIGNMENT + 1) -#define OPTION_MAJOR_IMAGE_VERSION (OPTION_IMAGE_BASE + 1) -#define OPTION_MAJOR_OS_VERSION (OPTION_MAJOR_IMAGE_VERSION + 1) -#define OPTION_MAJOR_SUBSYSTEM_VERSION (OPTION_MAJOR_OS_VERSION + 1) -#define OPTION_MINOR_IMAGE_VERSION (OPTION_MAJOR_SUBSYSTEM_VERSION + 1) -#define OPTION_MINOR_OS_VERSION (OPTION_MINOR_IMAGE_VERSION + 1) -#define OPTION_MINOR_SUBSYSTEM_VERSION (OPTION_MINOR_OS_VERSION + 1) -#define OPTION_SECTION_ALIGNMENT (OPTION_MINOR_SUBSYSTEM_VERSION + 1) -#define OPTION_STACK (OPTION_SECTION_ALIGNMENT + 1) -#define OPTION_SUBSYSTEM (OPTION_STACK + 1) -#define OPTION_HEAP (OPTION_SUBSYSTEM + 1) - static void gld${EMULATION_NAME}_add_options (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl, diff --git a/ld/emultempl/bfin.em b/ld/emultempl/bfin.em index eb13055..4b9be67 100644 --- a/ld/emultempl/bfin.em +++ b/ld/emultempl/bfin.em @@ -39,11 +39,6 @@ EOF # Define some shell vars to insert bits of code into the standard elf # parse_args and list_options functions. # -PARSE_AND_LIST_PROLOGUE=' -#define OPTION_CODE_IN_L1 300 -#define OPTION_DATA_IN_L1 301 -' - PARSE_AND_LIST_LONGOPTS=' { "code-in-l1", no_argument, NULL, OPTION_CODE_IN_L1 }, { "data-in-l1", no_argument, NULL, OPTION_DATA_IN_L1 }, diff --git a/ld/emultempl/cskyelf.em b/ld/emultempl/cskyelf.em index 82815e5..64a6ddf 100644 --- a/ld/emultempl/cskyelf.em +++ b/ld/emultempl/cskyelf.em @@ -288,12 +288,6 @@ EOF # This code gets inserted into the generic elf32.sc linker script # and allows us to define our own command line switches. -PARSE_AND_LIST_PROLOGUE=' -#define OPTION_BRANCH_STUB 301 -#define OPTION_NO_BRANCH_STUB 302 -#define OPTION_STUBGROUP_SIZE 303 -' - PARSE_AND_LIST_LONGOPTS=' {"branch-stub", no_argument, NULL, OPTION_BRANCH_STUB}, {"no-branch-stub", no_argument, NULL, OPTION_NO_BRANCH_STUB}, diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em index 71cec19..f551225 100644 --- a/ld/emultempl/elf.em +++ b/ld/emultempl/elf.em @@ -45,6 +45,7 @@ fragment < #include "elf-bfd.h" @@ -556,28 +557,7 @@ EOF fi fi -if test -n "$PARSE_AND_LIST_PROLOGUE" ; then fragment <