aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/ELFObjectWriter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-04-12[MC/ELFObjectWriter] Fix indentation of class body.David Blaikie1-131/+130
llvm-svn: 266136
2016-03-28Handle section vs global name conflict.Evgeniy Stepanov1-1/+16
This is a fix for PR26941. When there is both a section and a global definition with the same name, the global wins. Section symbols are not added to the symbol table; section references are left undefined and fixed up in the object writer unless they've been satisfied by some other definition. llvm-svn: 264649
2016-02-02Fix Clang-tidy readability-redundant-control-flow warnings; other minor fixes.Eugene Zelenko1-3/+2
Differential revision: http://reviews.llvm.org/D16793 llvm-svn: 259539
2016-01-20Accept subtractions involving a weak symbol.Rafael Espindola1-6/+0
When a symbol S shows up in an expression in assembly there are two possible interpretations * The expression is referring to the value of S in this file. * The expression is referring to the value after symbol resolution. In the first case the assembler can reason about the value and try to produce a relocation. In the second case, that is only possible if the symbol cannot be preempted. Assemblers are not very consistent about which interpretation gets used. This changes MC to agree with GAS in the case of an expression of the form "Sym - WeakSym". llvm-svn: 258329
2016-01-19Handle 64 bit offsets.Rafael Espindola1-1/+1
No tests since llvm-mc takes 14 seconds on it. I will try to improve it and then test. Part of pr26208. llvm-svn: 258129
2016-01-13Convert a few assert failures into proper errors.Rafael Espindola1-4/+4
Fixes PR25944. llvm-svn: 257697
2016-01-13Simplify. NFC.Rafael Espindola1-9/+9
llvm-svn: 257689
2015-12-17Avoid explicit relocation sorting most of the time.Rafael Espindola1-17/+6
These days relocations are created and stored in a deterministic way. The order they are created is also suitable for the .o file, so we don't need an explicit sort. The last remaining exception is MIPS. llvm-svn: 255902
2015-12-17Always sort by offset first. NFC.Rafael Espindola1-0/+16
Every target changing sortRelocs was first calling the parent implementation. Just run that first. llvm-svn: 255898
2015-11-17[Assembler] Make fatal assembler errors non-fatalOliver Stannard1-10/+20
Currently, if the assembler encounters an error after parsing (such as an out-of-range fixup), it reports this as a fatal error, and so stops after the first error. However, for most of these there is an obvious way to recover after emitting the error, such as emitting the fixup with a value of zero. This means that we can report on all of the errors in a file, not just the first one. MCContext::reportError records the fact that an error was encountered, so we won't actually emit an object file with the incorrect contents. Differential Revision: http://reviews.llvm.org/D14717 llvm-svn: 253328
2015-10-23Add a RAW mode to StringTableBuilder.Rafael Espindola1-2/+2
In this mode it just tries to tail merge the strings without imposing any other format constrains. It will not, for example, add a null byte between them. Also add support for keeping a tentative size and offset if we decide to not optimize after all. This will be used shortly in lld for merging SHF_STRINGS sections. llvm-svn: 251153
2015-10-22Avoid storing a second copy of each string in StringTableBuilder.Rafael Espindola1-3/+8
This was only use in the extremely uncommon case of @@@ symbols on ELF. llvm-svn: 251039
2015-10-05Fix pr24486.Rafael Espindola1-3/+0
This extends the work done in r233995 so that now getFragment (in addition to getSection) also works for variable symbols. With that the existing logic to decide if a-b can be computed works even if a or b are variables. Given that, the expression evaluation can avoid expanding variables as aggressively and that in turn lets the relocation code see the original variable. In order for this to work with the asm streamer, there is now a dummy fragment per section. It is used to assign a section to a symbol when no other fragment exists. This patch is a joint work by Maxim Ostapenko andy myself. llvm-svn: 249303
2015-09-01[MC] Allow MCObjectWriter's output stream to be swapped outDavid Majnemer1-55/+32
There are occasions where it is useful to consider the entirety of the contents of a section. For example, compressed debug info needs the entire section available before it can compress it and write it out. The compressed debug info scenario was previously implemented by mirroring the implementation of writeSectionData in the ELFObjectWriter. Instead, allow the output stream to be swapped on demand. This lets callers redirect the output stream to a more convenient location before it hits the object file. No functionality change is intended. Differential Revision: http://reviews.llvm.org/D12509 llvm-svn: 246554
2015-07-02Convert a member variable to a local one.Rafael Espindola1-3/+3
llvm-svn: 241284
2015-06-25Diagnose undefined temporary symbols.Rafael Espindola1-0/+5
We already disallowed .global .Lfoo so this is reasonable. This is a small cherry pick from r240130. llvm-svn: 240681
2015-06-23Revert r240302 ("Bring r240130 back.").Daniel Jasper1-10/+3
This causes errors like: ld: error: blah.o: requires dynamic R_X86_64_PC32 reloc against '' which may overflow at runtime; recompile with -fPIC blah.cc:function f(): error: undefined reference to '' blah.o:g(): error: undefined reference to '' I have not yet come up with an appropriate reproduction. llvm-svn: 240394
2015-06-23Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko1-1/+1
Apparently, the style needs to be agreed upon first. llvm-svn: 240390
2015-06-22Fix PR23914.Evgeniy Stepanov1-1/+1
r226830 moved the declaration of Buf to a nested scope, resulting in a dangling reference (in StringRef Name), and a use-after-free. llvm-svn: 240357
2015-06-22Bring r240130 back.Rafael Espindola1-3/+10
Now that pr23900 is fixed, we can bring it back with no changes. Original message: Make all temporary symbols unnamed. What this does is make all symbols that would otherwise start with a .L (or L on MachO) unnamed. Some of these symbols still show up in the symbol table, but we can just make them unnamed. In order to make sure we produce identical results when going thought assembly, all .L (not just the compiler produced ones), are now unnamed. Running llc on llvm-as.opt.bc, the peak memory usage goes from 208.24MB to 205.57MB. llvm-svn: 240302
2015-06-20Update ELFObjectWriter::reset() following r238073.Yaron Keren1-0/+1
llvm-svn: 240218
2015-06-19Revert 240130, it caused crashes (repro in PR23900).Nico Weber1-10/+3
llvm-svn: 240193
2015-06-19Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-1/+1
The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
2015-06-19Make all temporary symbols unnamed.Rafael Espindola1-3/+10
What this does is make all symbols that would otherwise start with a .L (or L on MachO) unnamed. Some of these symbols still show up in the symbol table, but we can just make them unnamed. In order to make sure we produce identical results when going thought assembly, all .L (not just the compiler produced ones), are now unnamed. Running llc on llvm-as.opt.bc, the peak memory usage goes from 208.24MB to 205.57MB. llvm-svn: 240130
2015-06-05Refactor padding writing into a helper function.Rafael Espindola1-12/+12
llvm-svn: 239174
2015-06-05Save a map lookup. NFC.Rafael Espindola1-2/+4
llvm-svn: 239168
2015-06-04MC: Clean up the naming for MCMachObjectWriter. NFC.Jim Grosbach1-2/+2
s/ExecutePostLayoutBinding/executePostLayoutBinding/ s/ComputeSymbolTable/computeSymbolTable/ s/BindIndirectSymbols/bindIndirectSymbols/ s/RecordTLVPRelocation/recordTLVPRelocation/ s/RecordScatteredRelocation/recordScatteredRelocation/ s/WriteLinkerOptionsLoadCommand/writeLinkerOptionsLoadCommand/ s/WriteLinkeditLoadCommand/writeLinkeditLoadCommand/ s/WriteNlist/writeNlist/ s/WriteDysymtabLoadCommand/writeDysymtabLoadCommand/ s/WriteSymtabLoadCommand/writeSymtabLoadCommand/ s/WriteSection/writeSection/ s/WriteSegmentLoadCommand/writeSegmentLoadCommand/ s/WriteHeader/writeHeader/ llvm-svn: 239119
2015-06-04MC: Clean up naming in MCObjectWriter. NFC.Jim Grosbach1-29/+29
s/WriteObject/writeObject/ s/RecordRelocation/recordRelocation/ s/IsSymbolRefDifferenceFullyResolved/isSymbolRefDifferenceFullyResolved/ s/Write8/write8/ s/WriteLE16/writeLE16/ s/WriteLE32/writeLE32/ s/WriteLE64/writeLE64/ s/WriteBE16/writeBE16/ s/WriteBE32/writeBE32/ s/WriteBE64/writeBE64/ s/Write16/write16/ s/Write32/write32/ s/Write64/write64/ s/WriteZeroes/writeZeroes/ s/WriteBytes/writeBytes/ llvm-svn: 239108
2015-06-04Remove unused argument. NFC.Rafael Espindola1-4/+3
llvm-svn: 239092
2015-06-04Omit unused section symbols from the symbol table.Rafael Espindola1-3/+5
Section symbols exist as an optimization: instead of having multiple relocations point to different symbols, many of them can point to a single section symbol. When that optimization is unused, a section symbol is also unused and adds no extra information to the object file. This saves a bit of space on the object files and makes the output of llvm-objdump -t easier to read and consequently some tests get quite a bit simpler. llvm-svn: 239045
2015-06-04Bring back r239006 with a fix.Rafael Espindola1-2/+1
The fix is just that getOther had not been updated for packing the st_other values in fewer bits and could return spurious values: - unsigned Other = (getFlags() & (0x3f << ELF_STO_Shift)) >> ELF_STO_Shift; + unsigned Other = (getFlags() & (0x7 << ELF_STO_Shift)) >> ELF_STO_Shift; Original message: Pack the MCSymbolELF bit fields into MCSymbol's Flags. This reduces MCSymolfELF from 64 bytes to 56 bytes on x86_64. While at it, also make getOther/setOther easier to use by accepting unshifted STO_* values. llvm-svn: 239012
2015-06-04Revert "Pack the MCSymbolELF bit fields into MCSymbol's Flags."Rafael Espindola1-1/+2
This reverts commit r239006. I am debugging the powerpc failures. llvm-svn: 239010
2015-06-04Pack the MCSymbolELF bit fields into MCSymbol's Flags.Rafael Espindola1-2/+1
This reduces MCSymolfELF from 64 bytes to 56 bytes on x86_64. While at it, also make getOther/setOther easier to use by accepting unshifted STO_* values. llvm-svn: 239006
2015-06-04Remove MCELFSymbolFlags.h. It is now internal to MCSymbolELF.Rafael Espindola1-3/+2
llvm-svn: 238996
2015-06-03Remember if a weakref of a symbol has been used.Rafael Espindola1-26/+14
This avoids yet another last minute patching of the binding. While at it, also simplify the weakref implementation a bit by not walking past it in the expression evaluation. llvm-svn: 238982
2015-06-03Store whether a symbol is a comdat signature in MCSymbolELF.Rafael Espindola1-21/+2
With this getBinging can now return the correct answer for all cases not involving a .symver and the elf writer doesn't need to patch it last minute. llvm-svn: 238980
2015-06-03Record in a MCSymbolELF if it has been used in a relocation.Rafael Espindola1-10/+6
No functionality change, just saves an on the side map. llvm-svn: 238979
2015-06-03Simplify the logic in ELFObjectWriter::isInSymtab. NFC.Rafael Espindola1-9/+5
_GLOBAL_OFFSET_TABLE_ is not magical and we can now directly check for a symbol never getting an explicit binding. llvm-svn: 238978
2015-06-02Pass a MCSymbolELF to a few ELF only functions. NFC.Rafael Espindola1-1/+1
llvm-svn: 238868
2015-06-02Merge MCELF.h into MCSymbolELF.h.Rafael Espindola1-36/+41
Now that we have a dedicated type for ELF symbol, these helper functions can become member function of MCSymbolELF. llvm-svn: 238864
2015-06-02Create a MCSymbolELF.Rafael Espindola1-3/+5
This create a MCSymbolELF class and moves SymbolSize since only ELF needs a size expression. This reduces the size of MCSymbol from 56 to 48 bytes. llvm-svn: 238801
2015-05-29Remove getData.Rafael Espindola1-22/+12
This completes the mechanical part of merging MCSymbol and MCSymbolData. llvm-svn: 238617
2015-05-29Remove the MCSymbolData typedef.Rafael Espindola1-6/+6
The getData member function is next. llvm-svn: 238611
2015-05-29Rename getOrCreateSymbolData to registerSymbol and return void.Rafael Espindola1-1/+1
Another step in merging MCSymbol and MCSymbolData. llvm-svn: 238607
2015-05-29Fix build without asserts.Rafael Espindola1-0/+2
llvm-svn: 238597
2015-05-29Pass MCSymbols to the helper functions in MCELF.h.Rafael Espindola1-33/+27
llvm-svn: 238596
2015-05-29Pass a MCSymbol to needsRelocateWithSymbol.Rafael Espindola1-1/+1
llvm-svn: 238589
2015-05-29Move common symbol related information from MCSectionData to MCSymbol.Rafael Espindola1-4/+4
llvm-svn: 238583
2015-05-29Move SymbolSize from MCSymbolData to MCSymbol.Rafael Espindola1-2/+2
llvm-svn: 238580
2015-05-29Simplify now that symbols contain the correct section.Rafael Espindola1-9/+4
The complexity in here was because before r233995 variable symbols would report the incorrect section. llvm-svn: 238559