OSDN Git Service

[LTO] Prevent dead stripping and internalization of symbols with sections
authorTeresa Johnson <tejohnson@google.com>
Tue, 25 Jul 2017 19:42:32 +0000 (19:42 +0000)
committerTeresa Johnson <tejohnson@google.com>
Tue, 25 Jul 2017 19:42:32 +0000 (19:42 +0000)
commita63ab3c9ea5b1ee11cc70c40985bd92437063df6
treeff105b15b2f3f1bbc0908e2a27638ee8bacc2ef2
parent94c534f4bd579f59d54512c861d2d238a23b05e3
[LTO] Prevent dead stripping and internalization of symbols with sections

Summary:
ELF linkers generate __start_<secname> and __stop_<secname> symbols
when there is a value in a section <secname> where the name is a valid
C identifier.  If dead stripping determines that the values declared
in section <secname> are dead, and we then internalize (and delete)
such a symbol, programs that reference the corresponding start and end
section symbols will get undefined reference linking errors.

To fix this, add the section name to the IRSymtab entry when a symbol is
defined in a specific section. Then use this in the gold-plugin to mark
the symbol as external and visible from outside the summary when the
section name is a valid C identifier.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, eraman, llvm-commits

Differential Revision: https://reviews.llvm.org/D35639

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309009 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/LTO/LTO.h
include/llvm/Object/IRSymtab.h
lib/Object/IRSymtab.cpp
test/Object/X86/irsymtab.ll
test/tools/gold/X86/Inputs/global_with_section.ll [new file with mode: 0644]
test/tools/gold/X86/global_with_section.ll [new file with mode: 0644]
tools/gold/gold-plugin.cpp
tools/llvm-lto2/llvm-lto2.cpp