diff options
-rw-r--r-- | ld/ChangeLog | 12 | ||||
-rw-r--r-- | ld/NEWS | 2 | ||||
-rw-r--r-- | ld/ld.h | 3 | ||||
-rw-r--r-- | ld/ld.texinfo | 11 | ||||
-rw-r--r-- | ld/ldemul.c | 4 | ||||
-rw-r--r-- | ld/ldlex.h | 2 | ||||
-rw-r--r-- | ld/lexsup.c | 10 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/elf.exp | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/orphan-5.l | 5 |
10 files changed, 67 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 7468a7d..4228732 100644 --- a/ld/ChangeLog +++ b/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. @@ -1,5 +1,7 @@ -*- text -*- +* Add --warn-orphan option to report orphan sections. + * Add support for LLVM plugin. Changes in 2.25: @@ -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; diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 440fa41..82735e9 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -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 diff --git a/ld/ldemul.c b/ld/ldemul.c index 8b2cae7..4898892 100644 --- a/ld/ldemul.c +++ b/ld/ldemul.c @@ -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 , diff --git a/ld/lexsup.c b/ld/lexsup.c index aa6c3cd..a30fafa 100644 --- a/ld/lexsup.c +++ b/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; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 49a74f7..ef54e67 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -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. diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index f126650..d1a70ea 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -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*] } { diff --git a/ld/testsuite/ld-elf/orphan-5.l b/ld/testsuite/ld-elf/orphan-5.l new file mode 100644 index 0000000..7b65af2 --- /dev/null +++ b/ld/testsuite/ld-elf/orphan-5.l @@ -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 +#... |