aboutsummaryrefslogtreecommitdiff
path: root/bfd/cofflink.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2019-03-15 22:19:01 +0800
committerH.J. Lu <hjl.tools@gmail.com>2019-03-15 22:19:20 +0800
commit2219ae0b0ebe14373850b000c2abaa31dab1d741 (patch)
tree8f138e44655f3af01b98d9567157c192f9d06ad2 /bfd/cofflink.c
parent1c82ed745bec154a3cd8a8bbf36c5be5086041d5 (diff)
downloadbinutils-2219ae0b0ebe14373850b000c2abaa31dab1d741.zip
binutils-2219ae0b0ebe14373850b000c2abaa31dab1d741.tar.gz
binutils-2219ae0b0ebe14373850b000c2abaa31dab1d741.tar.bz2
COFF: Check for symbols defined in discarded section
For LTO, a symbol may defined in discarded section. We should mark it as undefined so that LTO plugin will make IR definition available. PR ld/24267 * coffgen.c (_bfd_coff_section_already_linked): Skip discarded section. * cofflink.c (coff_link_add_symbols): Check for symbols defined in discarded section.
Diffstat (limited to 'bfd/cofflink.c')
-rw-r--r--bfd/cofflink.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index e4031b9..ac07d05 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -310,7 +310,9 @@ coff_link_add_symbols (bfd *abfd,
case COFF_SYMBOL_GLOBAL:
flags = BSF_EXPORT | BSF_GLOBAL;
section = coff_section_from_bfd_index (abfd, sym.n_scnum);
- if (! obj_pe (abfd))
+ if (discarded_section (section))
+ section = bfd_und_section_ptr;
+ else if (! obj_pe (abfd))
value -= section->vma;
break;
@@ -327,6 +329,8 @@ coff_link_add_symbols (bfd *abfd,
case COFF_SYMBOL_PE_SECTION:
flags = BSF_SECTION_SYM | BSF_GLOBAL;
section = coff_section_from_bfd_index (abfd, sym.n_scnum);
+ if (discarded_section (section))
+ section = bfd_und_section_ptr;
break;
}