aboutsummaryrefslogtreecommitdiff
path: root/ld/lexsup.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-05-27 04:53:54 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-05-27 04:54:10 -0700
commita6dbf402de65fe66f4ec99b56527dfd00d077cb6 (patch)
treea264f6b6544f748f3d7dea562ee44cb47a8d9dd1 /ld/lexsup.c
parent25e1eca8faf1c29d28e57b37d6b5e3810b7b870b (diff)
downloadgdb-a6dbf402de65fe66f4ec99b56527dfd00d077cb6.zip
gdb-a6dbf402de65fe66f4ec99b56527dfd00d077cb6.tar.gz
gdb-a6dbf402de65fe66f4ec99b56527dfd00d077cb6.tar.bz2
ld: Add --warn-textrel and obsolete --warn-shared-textrel
--warn-shared-textrel and -z text apply to both shared object and PIE. Add --warn-textrel and obsolete --warn-shared-textrel. Consolidate --warn-textrel and -z text/notext/textoff implementation. bfd/ PR ld/22909 * elflink.c (bfd_elf_final_link): Use bfd_link_textrel_check. Check bfd_link_dll when issue a DT_TEXTREL warning. * elfxx-x86.c (maybe_set_textrel): Likewise. (_bfd_x86_elf_size_dynamic_sections): Likewise. include/ PR ld/22909 * bfdlink.h (textrel_check_method): New enum. (bfd_link_textrel_check): New. (bfd_link_info): Replace warn_shared_textrel and error_textrel with textrel_check. ld/ PR ld/22909 * NEWS: Mention --warn-textrel. * ld.texi: Update -z text/notext/textoff. Add --warn-textrel. Remove --warn-shared-textrel. * ldlex.h (option_values): Rename OPTION_WARN_SHARED_TEXTREL to OPTION_WARN_TEXTREL. * lexsup.c (ld_options): Add --warn-textrel. Obsolete --warn-shared-textrel. (parse_args): Updated. (elf_shlib_list_options): Check link_info.textrel_check. * emultempl/elf.em: Updated. * testsuite/ld-elf/pr19539.d: Replace -z notext with --warn-textrel. Expect a warning. * testsuite/ld-i386/warn1.d: Update expected warning.
Diffstat (limited to 'ld/lexsup.c')
-rw-r--r--ld/lexsup.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 04db2f1..3733a7c 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -516,9 +516,11 @@ static const struct ld_option ld_options[] =
{ {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
'\0', NULL, N_("Warn if start of section changes due to alignment"),
TWO_DASHES },
- { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_SHARED_TEXTREL},
- '\0', NULL, N_("Warn if shared object has DT_TEXTREL"),
+ { {"warn-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
+ '\0', NULL, N_("Warn if outpout has DT_TEXTREL"),
TWO_DASHES },
+ { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
+ '\0', NULL, NULL, NO_HELP },
{ {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM},
'\0', NULL, N_("Warn if an object has alternate ELF machine code"),
TWO_DASHES },
@@ -1438,8 +1440,8 @@ parse_args (unsigned argc, char **argv)
case OPTION_WARN_SECTION_ALIGN:
config.warn_section_align = TRUE;
break;
- case OPTION_WARN_SHARED_TEXTREL:
- link_info.warn_shared_textrel = TRUE;
+ case OPTION_WARN_TEXTREL:
+ link_info.textrel_check = textrel_check_warning;
break;
case OPTION_WARN_ALTERNATE_EM:
link_info.warn_alternate_em = TRUE;
@@ -1846,12 +1848,26 @@ elf_shlib_list_options (FILE *file)
-z nocommon Generate common symbols with STT_OBJECT type\n"));
fprintf (file, _("\
-z stack-size=SIZE Set size of stack segment\n"));
- fprintf (file, _("\
- -z text Treat DT_TEXTREL in shared object as error\n"));
- fprintf (file, _("\
- -z notext Don't treat DT_TEXTREL in shared object as error\n"));
- fprintf (file, _("\
- -z textoff Don't treat DT_TEXTREL in shared object as error\n"));
+ if (link_info.textrel_check == textrel_check_error)
+ fprintf (file, _("\
+ -z text Treat DT_TEXTREL in output as error (default)\n"));
+ else
+ fprintf (file, _("\
+ -z text Treat DT_TEXTREL in output as error\n"));
+ if (link_info.textrel_check == textrel_check_none)
+ {
+ fprintf (file, _("\
+ -z notext Don't treat DT_TEXTREL in output as error (default)\n"));
+ fprintf (file, _("\
+ -z textoff Don't treat DT_TEXTREL in output as error (default)\n"));
+ }
+ else
+ {
+ fprintf (file, _("\
+ -z notext Don't treat DT_TEXTREL in output as error\n"));
+ fprintf (file, _("\
+ -z textoff Don't treat DT_TEXTREL in output as error\n"));
+ }
}
static void