llvm/lib/Object
Tobias Edler von Koch 7f80f1bbf5 LTO: Pass SF_Executable flag through to InputFile::Symbol
Summary:
The linker needs to be able to determine whether a symbol is text or data to
handle the case of a common being overridden by a strong definition in an
archive. If the archive contains a text member of the same name as the common,
that function is discarded. However, if the archive contains a data member of
the same name, that strong definition overrides the common. This is a behavior
of ld.bfd, which the Qualcomm linker also supports in LTO.

Here's a test case to illustrate:

####

cat > 1.c << \!
int blah;
!

cat > 2.c << \!
int blah() {
  return 0;
}
!

cat > 3.c << \!
int blah = 20;
!

clang -c 1.c
clang -c 2.c
clang -c 3.c

ar cr lib.a 2.o 3.o
ld 1.o lib.a -t

####

The correct output is:

1.o
(lib.a)3.o

Thanks to Shankar Easwaran and Hemant Kulkarni for the test case!

Reviewers: mehdi_amini, rafael, pcc, davide

Reviewed By: pcc

Subscribers: davide, llvm-commits, inglorion

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300205 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 16:24:14 +00:00
..
Archive.cpp
ArchiveWriter.cpp ArchiveWriter: Remove unused variables. NFC. 2017-03-16 20:35:07 +00:00
Binary.cpp
CMakeLists.txt Re-apply r299168 and r299169 now that the libdeps are fixed. 2017-03-31 04:47:07 +00:00
COFFObjectFile.cpp
Decompressor.cpp Recommit r292214 "[Support/Compression] - Change zlib API to return Error instead of custom status" 2017-01-17 15:45:07 +00:00
ELF.cpp
ELFObjectFile.cpp [ARM] Create SubtargetFeatures from build attrs 2017-01-18 15:52:11 +00:00
Error.cpp
IRObjectFile.cpp [ThinLTO] Import composite types as declarations 2016-12-16 21:25:01 +00:00
IRSymtab.cpp LTO: Pass SF_Executable flag through to InputFile::Symbol 2017-04-13 16:24:14 +00:00
LLVMBuild.txt
MachOObjectFile.cpp Remove unused functions. Remove static qualifier from functions in header files. NFC. 2017-04-11 14:55:32 +00:00
MachOUniversal.cpp Fix a bugs with using some Mach-O command line flags like "-arch armv7m". 2016-12-16 22:54:02 +00:00
ModuleSummaryIndexObjectFile.cpp [ThinLTO] Add support for emitting minimized bitcode for thin link 2017-03-23 19:47:39 +00:00
ModuleSymbolTable.cpp Add ifunc support to ModuleSymbolTable. 2017-03-29 19:26:26 +00:00
Object.cpp
ObjectFile.cpp
RecordStreamer.cpp Fix typo, defind -> defined. 2017-03-31 01:46:30 +00:00
RecordStreamer.h Perform symbol binding for .symver versioned symbols 2017-03-09 00:19:49 +00:00
SymbolicFile.cpp
SymbolSize.cpp
WasmObjectFile.cpp [WASM] Remove other comparison of unsigned expression >= 0. 2017-04-01 19:47:52 +00:00