From 3ea6077552ad86ebb441bef6e1bd40e18d06ab44 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 7 Apr 2015 16:29:41 +0100 Subject: 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. --- ld/ldemul.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ld/ldemul.c') 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; -- cgit v1.1