With fix: commit changes from InputFiles.cpp too.
Original commit message:
We have following code in lld, that truncates the alignment value to 32 bit. Big alignment in this case
may give result 0 and crash later.
template <class ELFT>
CommonInputSection<ELFT>::CommonInputSection(std::vector<DefinedCommon *> Syms)
: InputSection<ELFT>(nullptr, &Hdr, "") {
....
for (DefinedCommon *Sym : Syms) {
this->Alignment = std::max<uintX_t>(this->Alignment, Sym->Alignment);
...
}
}
Patch fixes the issue.
Differential revision: https://reviews.llvm.org/D25235
llvm-svn: 283738
.ARM.exidx sections have a reverse dependency on the section they have
a SHF_LINK_ORDER dependency on. In other words a .ARM.exidx section is
live only if the executable section it describes is live. We implement
this with a reverse dependency field in InputSection.
Adding the dependency to InputSection is the simplest implementation
but it could be moved out to a separate map if it were found to decrease
performance for non ARM targets.
Differential revision: https://reviews.llvm.org/D25234
llvm-svn: 283734
When sh_info of sumbol table value was set to zero, lld was asserting.
Patch fixes the issue.
Differential revision: https://reviews.llvm.org/D25016
llvm-svn: 283562
Previously if sh_size of dynamic section was broken,
lld may crash. Or even may not crash if used 32 bits host.
(then value may be truncated to 32 bits when doing pointer arithmetic
and could be just zero).
Patch fixes the issue.
Differential revision: https://reviews.llvm.org/D25327
llvm-svn: 283533
createELFObj() may call error(...), for example when file is too short.
In that case header is not set and following line lead to crash:
EMachine = ELFObj.getHeader()->e_machine;
Patch fixes the issue.
Differential revision: https://reviews.llvm.org/D25233
llvm-svn: 283532
This patch makes the check for null section stricter,
so it is only allowed for STT_SECTION symbols now.
Differential revision: https://reviews.llvm.org/D25231
llvm-svn: 283426
Do not merge sections if generating a relocatable object. It makes
the code simpler because we do not need to update relocations addends
to reflect changes introduced by merging. Instead of that we write
such "merge" sections into separate OutputSections and keep SHF_MERGE
/ SHF_STRINGS flags and sh_entsize value to be able to perform merging
later during a final linking.
Differential Revision: http://reviews.llvm.org/D25066
llvm-svn: 283300
Testcase contains a common symbol with zero alignment,
previously lld would crash, patch fixes that.
Differential revision: https://reviews.llvm.org/D25085
llvm-svn: 283197
This was intended to warn on a usage error of an ar command.
I was thinking that false positive would be rare because it
has two guards: it warns only when an archive file has no symbols
and contains at least one file.
Turned out that false positive would probably be not that rare.
You wouldn't intentionally create an object file that contains no
exported symbols, but with conditional compile guards, you could
create such file. If it is for a LTO build, you could create an
archive file containing such file. That means there's no way to
detect the usage error in a reliable manner.
This patch simply removes the warning.
llvm-svn: 282916
Previously, it warned on any archive file that has no symbol.
It turned out that that is too noisy.
With this patch, it warns on such archive file that contains no file.
Differential Revision: https://reviews.llvm.org/D25111
llvm-svn: 282885
This surfaced again with Rust. As per bug 30435, rustc creates a
mergeable section with a sh_entsize zero. It bit us before, too.
I think we should relax the input check rather than being too picky.
Differential Revision: https://reviews.llvm.org/D24789
llvm-svn: 282049
Previously, all input files were owned by the symbol table.
Files were created at various places, such as the Driver, the lazy
symbols, or the bitcode compiler, and the ownership of new files
was transferred to the symbol table using std::unique_ptr.
All input files were then free'd when the symbol table is freed
which is on program exit.
I think we don't have to transfer ownership just to free all
instance at once on exit.
In this patch, all instances are automatically collected to a
vector and freed on exit. In this way, we no longer have to
use std::unique_ptr.
Differential Revision: https://reviews.llvm.org/D24493
llvm-svn: 281425
Implemented by building an ELF file in memory.
elf, default, and binary match gold behavior.
Differential Revision: https://reviews.llvm.org/D24060
llvm-svn: 281108
This simplifies error handling as there is now only one place in the
code that needs to consider the possibility that the name is
corrupted. Before we would do it in every access.
llvm-svn: 280937
This approach is not only consistent with UnresolvedPolicy,
but also should help to solve a problem
of options with opposing meanings, mentioned in PR28843
Differential revision: https://reviews.llvm.org/D23869
llvm-svn: 280206
After latest changes we combine input sections with
different attributes into single output section.
Problem here is that regular output sections does not
support adding mergeable input sections (and vise versa).
Patch just temporarily disables merging for now at
the same way we do for -O0 for example.
This change helps for linking FreeBSD kernel.
Differential revision: https://reviews.llvm.org/D23447
llvm-svn: 278555
We found that GNU assembler 2.17.50 [FreeBSD] 2007-07-03
could generate broken objects. STT_SECTION symbols can be
associated with SHT_REL[A]/SHT_SYMTAB/SHT_STRTAB sections.
This is PR28868, patch fixes handling of such files.
Differential revision: https://reviews.llvm.org/D23201
llvm-svn: 278550
This section supersedes .reginfo and .MIPS.options sections. But for now
we have to support all three sections for ABI transition period.
llvm-svn: 278482
Mergeable sections with size zero are useless because they don't
actually contain data, and therefore there's no merit ot merge them.
However, in reality, there are object files in the wild containing
such sections. Currently, LLD can't handle them proerply.
This patch makes LLD to handle such sections as if they are non-
mergeable to fix the issue.
Fixes bug 28822.
llvm-svn: 277568
We already have code for ARM in initializeSections, so this
is more consistent.
Differential Revision: https://reviews.llvm.org/D22833
llvm-svn: 276811
--trace-symbol is a command line option to watch a symbol.
Previosly, we looked up a hash table for a new symbol if the
option is given. Any code that looks up a hash table for each
symbol is expensive because the linker handles a lot of symbols.
In our design, we look up a hash table strictly only once
for a symbol, so --trace-symbol was an exception.
This patch improves efficiency of the option by merging the
hash table into the symbol table.
Instead of looking up a separate hash table with a string,
this patch sets `Traced` flag to symbols specified by --trace-symbol.
So, if you insert a symbol and get a symbol with `Traced` flag on,
you know that you need to print out a log message for the symbol.
This is nearly zero cost.
llvm-svn: 275716
Previously, each subclass of SymbolBody had a pointer to a source
file from which it was created. So, there was no single way to get
a source file for a symbol. We had getSourceFile<ELFT>(), but the
function was a bit inconvenient as it's a template.
This patch makes SymbolBody have a pointer to a source file.
If a symbol is not created from a file, the pointer has a nullptr.
llvm-svn: 275701