Add new linker option: --warn-orphan which generates warning messages when orphan sections are detected.
ld * ld.h (struct ld_config_type): Add new field: warn_orphan. * ldlex.h (enum option_values): Add OPTION_WARN_ORPHAN and OPTION_NO_WARN_ORPHAN. * lexsup.c (ld_options): Add --warn-orphan and --no-warn-orphan. (parse_args): Handle the new options. * ldemul.c (ldemul_place_orphan): If requested, generate a warning message when an orphan section is placed in the output file. * ld.texinfo: Document the new option. * NEWS: Mention the new feature. tests * ld-elf/orphan-5.l: New test - checks the linker's output with --warn-orphan enabled. * ld-elf/elf.exp: Run the new test.
This commit is contained in:
parent
8a06aea71e
commit
3ea6077552
12
ld/ChangeLog
12
ld/ChangeLog
|
@ -9,6 +9,18 @@
|
|||
(params): Init new field.
|
||||
(ppc_before_allocation): Enable relaxation for pic_fixup.
|
||||
|
||||
2015-04-07 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* ld.h (struct ld_config_type): Add new field: warn_orphan.
|
||||
* ldlex.h (enum option_values): Add OPTION_WARN_ORPHAN and
|
||||
OPTION_NO_WARN_ORPHAN.
|
||||
* lexsup.c (ld_options): Add --warn-orphan and --no-warn-orphan.
|
||||
(parse_args): Handle the new options.
|
||||
* ldemul.c (ldemul_place_orphan): If requested, generate a warning
|
||||
message when an orphan section is placed in the output file.
|
||||
* ld.texinfo: Document the new option.
|
||||
* NEWS: Mention the new feature.
|
||||
|
||||
2015-04-02 Andrew Turner <andrew@freebsd.org>
|
||||
|
||||
* Makefile.am: Add FreeBSD aarch64 files.
|
||||
|
|
2
ld/NEWS
2
ld/NEWS
|
@ -1,5 +1,7 @@
|
|||
-*- text -*-
|
||||
|
||||
* Add --warn-orphan option to report orphan sections.
|
||||
|
||||
* Add support for LLVM plugin.
|
||||
|
||||
Changes in 2.25:
|
||||
|
|
3
ld/ld.h
3
ld/ld.h
|
@ -226,6 +226,9 @@ typedef struct {
|
|||
/* If TRUE, only warn once about a particular undefined symbol. */
|
||||
bfd_boolean warn_once;
|
||||
|
||||
/* If TRUE, issue warning messages when orphan sections are encountered. */
|
||||
bfd_boolean warn_orphan;
|
||||
|
||||
/* If TRUE, warn if multiple global-pointers are needed (Alpha
|
||||
only). */
|
||||
bfd_boolean warn_multiple_gp;
|
||||
|
|
|
@ -2064,6 +2064,17 @@ option causes a warning to be issued whenever this case occurs.
|
|||
Only warn once for each undefined symbol, rather than once per module
|
||||
which refers to it.
|
||||
|
||||
@kindex --warn-orphan
|
||||
@kindex --no-warn-orphan
|
||||
@cindex warnings, on orphan sections
|
||||
@cindex orphan sections, warnings on
|
||||
@item --warn-orphan
|
||||
The @option{--warn-orphan} option tells the linker to generate a
|
||||
warning message whenever it has to place an orphan section into the
|
||||
output file. @xref{Orphan Sections} The @option{--no-warn-orphan}
|
||||
option restores the default behaviour of just silently placing these
|
||||
sections.
|
||||
|
||||
@kindex --warn-section-align
|
||||
@cindex warnings, on section alignment
|
||||
@cindex section alignment, warnings on
|
||||
|
|
|
@ -120,6 +120,10 @@ ldemul_open_dynamic_archive (const char *arch, search_dirs_type *search,
|
|||
lang_output_section_statement_type *
|
||||
ldemul_place_orphan (asection *s, const char *name, int constraint)
|
||||
{
|
||||
if (config.warn_orphan)
|
||||
einfo (_("%P: Warning: input section '%s' from file '%B' is not mentioned in linker script\n"),
|
||||
name, s->owner);
|
||||
|
||||
if (ld_emulation->place_orphan)
|
||||
return (*ld_emulation->place_orphan) (s, name, constraint);
|
||||
return NULL;
|
||||
|
|
|
@ -85,6 +85,8 @@ enum option_values
|
|||
OPTION_NO_WARN_FATAL,
|
||||
OPTION_WARN_MULTIPLE_GP,
|
||||
OPTION_WARN_ONCE,
|
||||
OPTION_WARN_ORPHAN,
|
||||
OPTION_NO_WARN_ORPHAN,
|
||||
OPTION_WARN_SECTION_ALIGN,
|
||||
OPTION_SPLIT_BY_RELOC,
|
||||
OPTION_SPLIT_BY_FILE ,
|
||||
|
|
10
ld/lexsup.c
10
ld/lexsup.c
|
@ -489,6 +489,10 @@ static const struct ld_option ld_options[] =
|
|||
'\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
|
||||
{ {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
|
||||
'\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
|
||||
{ {"warn-orphan", no_argument, NULL, OPTION_WARN_ORPHAN},
|
||||
'\0', NULL, N_("Warn if any orphan sections are encountered"), TWO_DASHES },
|
||||
{ {"no-warn-orphan", no_argument, NULL, OPTION_NO_WARN_ORPHAN},
|
||||
'\0', NULL, N_("Do not warn if orphan sections are encountered (default)"), TWO_DASHES },
|
||||
{ {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
|
||||
'\0', NULL, N_("Warn if start of section changes due to alignment"),
|
||||
TWO_DASHES },
|
||||
|
@ -1350,6 +1354,12 @@ parse_args (unsigned argc, char **argv)
|
|||
case OPTION_WARN_ONCE:
|
||||
config.warn_once = TRUE;
|
||||
break;
|
||||
case OPTION_WARN_ORPHAN:
|
||||
config.warn_orphan = TRUE;
|
||||
break;
|
||||
case OPTION_NO_WARN_ORPHAN:
|
||||
config.warn_orphan = FALSE;
|
||||
break;
|
||||
case OPTION_WARN_SECTION_ALIGN:
|
||||
config.warn_section_align = TRUE;
|
||||
break;
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
* ld-tic6x/shlib-app-1rb.rd: Likewise.
|
||||
* ld-tic6x/shlib-noindex.rd: Likewise.
|
||||
|
||||
2015-04-07 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* ld-elf/orphan-5.l: New test - checks the linker's output with
|
||||
--warn-orphan enabled.
|
||||
* ld-elf/elf.exp: Run the new test.
|
||||
|
||||
2015-04-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* ld-elf/compress.exp: Remove is_zlib_supported check.
|
||||
|
|
|
@ -116,6 +116,18 @@ foreach t $test_list {
|
|||
run_dump_test [file rootname $t]
|
||||
}
|
||||
|
||||
# Check that the --warn-orphan option works correctly.
|
||||
run_ld_link_tests {
|
||||
{"Report orphan sections"
|
||||
"--script orphan.ld --warn-orphan"
|
||||
""
|
||||
""
|
||||
{orphan.s}
|
||||
{ { ld "orphan-5.l" } }
|
||||
"orphan"
|
||||
}
|
||||
}
|
||||
|
||||
if { [istarget *-*-linux*]
|
||||
|| [istarget *-*-nacl*]
|
||||
|| [istarget *-*-gnu*] } {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#...
|
||||
.*Warning: input section '.notbad' from file 'tmpdir/orphan.o' is not mentioned in linker script
|
||||
#...
|
||||
.*Warning: input section '.note.bar' from file 'tmpdir/orphan.o' is not mentioned in linker script
|
||||
#...
|
Loading…
Reference in New Issue