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.
(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.
-*- text -*-
+* Add --warn-orphan option to report orphan sections.
+
* Add support for LLVM plugin.
Changes in 2.25:
/* 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;
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
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;
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 ,
'\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 },
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;
* 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.
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*] } {
--- /dev/null
+#...
+.*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
+#...