summaryrefslogtreecommitdiffstats
path: root/llvm/test/MC/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix a regression in .pop_section.Rafael Espindola2015-06-081-0/+21
| | | | | | | It was calling ChangeSection with the wrong current section, eventually leading to a crash. llvm-svn: 239335
* [MC] Common symbols weren't being checked for redeclaration which allowed an ↵Colin LeMahieu2015-06-062-0/+10
| | | | | | assembly file to generate an assertion in setCommon(): !isCommon(). This change allows redeclaration as long as the size and alignment match exactly, otherwise report a fatal error. llvm-svn: 239227
* Handle 16 bit PC relative relocations.Rafael Espindola2015-06-061-0/+5
| | | | | | Fixes pr23771. llvm-svn: 239214
* Omit unused section symbols from the symbol table.Rafael Espindola2015-06-0414-126/+50
| | | | | | | | | | | | | | 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
* Fix the interpretation of a 0 st_name.Rafael Espindola2015-06-0312-117/+39
| | | | | | | | | | | | | | The ELF spec is very clear: ----------------------------------------------------------------------------- If the value is non-zero, it represents a string table index that gives the symbol name. Otherwise, the symbol table entry has no name. -------------------------------------------------------------------------- In particular, a st_name of 0 most certainly doesn't mean that the symbol has the same name as the section. llvm-svn: 238899
* Don't special case undefined symbol when deciding the symbol order.Rafael Espindola2015-05-283-17/+17
| | | | | | | | | ELF has no restrictions on where undefined symbols go relative to other defined symbols. In fact, gas just sorts them together. Do the same. This was there since r111174 probably just because the MachO writer has it. llvm-svn: 238513
* Don't create an unused _GLOBAL_OFFSET_TABLE_.Rafael Espindola2015-05-282-38/+5
| | | | | | | | This was a bug for bug compatibility with gas that is completely unnecessary. If a _GLOBAL_OFFSET_TABLE_ symbol is used, it will already be created by the time we get to the ELF writer. llvm-svn: 238432
* Produce a single string table in a ELF .oRafael Espindola2015-05-222-19/+6
| | | | | | | | | | | | | | | | | | | | Normally an ELF .o has two string tables, one for symbols, one for section names. With the scheme of naming sections like ".text.foo" where foo is a symbol, there is a big potential saving in using a single one. Building llvm+clang+lld with master and with this patch the results were: master: 193,267,008 bytes patch: 186,107,952 bytes master non unique section names: 183,260,192 bytes patch non unique section names: 183,118,632 bytes So using non usique saves 10,006,816 bytes, and the patch saves 7,159,056 while still using distinct names for the sections. llvm-svn: 238073
* Relax these tests a bit.Rafael Espindola2015-05-227-18/+18
| | | | | | It is not relevant where in the string table the name is located. llvm-svn: 238053
* [DWARF] Add CIE header fields address_size and segment_size when generating ↵Keith Walker2015-05-122-6/+27
| | | | | | | | | | | | | dwarf-4 The DWARF-4 specification added 2 new fields in the CIE header called address_size and segment_size. Create these 2 new fields when generating dwarf-4 CIE entries, print out the new fields when dumping the CIE and update tests Differential Revision: http://reviews.llvm.org/D9558 llvm-svn: 237145
* Respect object format choice on DarwinKeno Fischer2015-05-041-0/+10
| | | | | | | | | | | | | | | Summary: The object format can be set to something other than MachO, e.g. to use ELF-on-Darwin for MCJIT. This already works on Windows, so there's no reason it shouldn't on Darwin. Reviewers: lhames, grosbach Subscribers: rafael, grosbach, t.p.northover, llvm-commits Differential Revision: http://reviews.llvm.org/D6185 llvm-svn: 236455
* Write sections mostly in one pass.Rafael Espindola2015-04-304-23/+31
| | | | | | | | | | | During ELF writing, there is no need to further relax the sections, so we should not be creating fragments. This patch avoids doing so in all cases but debug section compression (that is next). Also, the ELF format is fairly simple to write. We can do a single pass over the sections to write them out and compute the section header table. llvm-svn: 236235
* Don't check for offsets in tests where it is not relevant.Rafael Espindola2015-04-303-12/+12
| | | | llvm-svn: 236233
* Write the section header string table directly to the output stream.Rafael Espindola2015-04-298-50/+51
| | | | | | | | | | Instead of accumulating the content in a fragment first, just write it to the output stream. Also put it first in the section table, so that we never have to worry about its index being >= SHN_LORESERVE. llvm-svn: 236145
* IR: Give 'DI' prefix to debug info metadataDuncan P. N. Exon Smith2015-04-291-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Finish off PR23080 by renaming the debug info IR constructs from `MD*` to `DI*`. The last of the `DIDescriptor` classes were deleted in r235356, and the last of the related typedefs removed in r235413, so this has all baked for about a week. Note: If you have out-of-tree code (like a frontend), I recommend that you get everything compiling and tests passing with the *previous* commit before updating to this one. It'll be easier to keep track of what code is using the `DIDescriptor` hierarchy and what you've already updated, and I think you're extremely unlikely to insert bugs. YMMV of course. Back to *this* commit: I did this using the rename-md-di-nodes.sh upgrade script I've attached to PR23080 (both code and testcases) and filtered through clang-format-diff.py. I edited the tests for test/Assembler/invalid-generic-debug-node-*.ll by hand since the columns were off-by-three. It should work on your out-of-tree testcases (and code, if you've followed the advice in the previous paragraph). Some of the tests are in badly named files now (e.g., test/Assembler/invalid-mdcompositetype-missing-tag.ll should be 'dicompositetype'); I'll come back and move the files in a follow-up commit. llvm-svn: 236120
* Don't constrain the section order in tests that don't depend on it.Rafael Espindola2015-04-2934-169/+143
| | | | llvm-svn: 236102
* Use CIE version 4 for dwarf4.Rafael Espindola2015-04-282-7/+11
| | | | | | | According to http://www.dwarfstd.org/doc/DWARF4.pdf appendix F the CIE version for dwarf 4 is 4. llvm-svn: 235988
* [MC] Use LShr for constant evaluation of ">>" on ELF/arm64--darwin.Ahmed Bougacha2015-04-281-1/+1
| | | | | | | | | | This matches other assemblers and is less unexpected (e.g. PR23227). On ELF, I tried binutils gas v2.24 and nasm 2.10.09, and they both agree on LShr. On COFF, I couldn't get my hands on an assembler yet, so don't change the behavior. For now, don't change it on non-AArch64 Darwin either, as the other assembler is gas v1.38, which does an AShr. llvm-svn: 235963
* Use CIE version 1 for .eh_frame.Rafael Espindola2015-04-2719-54/+54
| | | | | | | | | | According to http://www.linuxbase.org/betaspecs/lsb/LSB-Core-generic/LSB-Core-generic/ehframechpt.html we should always use 1. llvm-svn: 235923
* Look past locals in comdats.Rafael Espindola2015-04-201-0/+2
| | | | | | | | | | | We have to avoid converting a reference to a global into a reference to a local, but it is fine to look past a local. Patch by Vasileios Kalintiris. I just moved the comment and added thet test. llvm-svn: 235300
* Compute A-B when A or B is weak.Rafael Espindola2015-04-172-12/+16
| | | | | | | | | | | | | | | | | | | | Similar to r235222, but for the weak symbol case. In an "ideal" assembler/object format an expression would always refer to the final value and A-B would only be computed from a section in the same comdat as A and B with A and B strong. Unfortunately that is not the case with debug info on ELF, so we need an heuristic. Since we need an heuristic, we may as well use the same one as gas: * call weak_sym : produces a relocation, even if in the same section. * A - weak_sym and weak_sym -A: don't produce a relocation if we can compute it. This fixes pr23272 and changes the fix of pr22815 to match what gas does. llvm-svn: 235227
* Compute A-B if both A and B are in the same comdat section.Rafael Espindola2015-04-171-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of pr23272. A small annoyance with the assembly syntax we implement is that given an expression there is no way to know if what is desired is the value of that expression for the symbols in this file or for the final values of those symbols in a link. The first case is useful for use in sections that get discarded or ignored if the section they are describing is discarded. For axample, consider A-B where A and B are in the same comdat section. We can compute the value of the difference in the section that is present in the current .o and if that section survives to the final DSO the value will still will be correct. But the section is in a comdat. Another section from another object file might be used istead. We know that that section will define A and B, but we have no idea what the value of A-B might be. In practice we have to assume that the intention is to compute the value in the current section since otherwise the is no way to create something like the debug aranges section. llvm-svn: 235222
* Don't walk aliases from global to local symbols in comdats.Rafael Espindola2015-04-171-0/+18
| | | | | | This fixes pr23196. llvm-svn: 235167
* Write relocation sections contiguously.Rafael Espindola2015-04-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linkers normally read all the relocations upfront to compute the references between sections. Putting them together is a bit more cache friendly. I benchmarked linking a Release+Asserts clang with gold on a vm. I tried all 4 combinations of --gc-sections/no --gc-section hot and cold cache. I cleared the cache with echo 3 > /proc/sys/vm/drop_caches and warmed it up by running the link once before timing the subsequent ones. With cold cache and --gc-sections the time goes from 1.86130781665 +- 0.01713126697463843 seconds to 1.82370735105 +- 0.014127522318814516 seconds With cold cache and no --gc-sections the time goes from 1.6087245435500002 +- 0.012999066825178644 seconds to 1.5687122041500001 +- 0.013145850126026619 seconds With hot cache and no --gc-sections the time goes from 0.926200939 ( +- 0.33% ) seconds to 0.907200079 ( +- 0.31% ) seconds With hot cache and gc sections the time goes from 1.183038049 ( +- 0.34% ) seconds to 1.147355862 ( +- 0.39% ) seconds llvm-svn: 235165
* Update tests to not be as dependent on section numbers.Rafael Espindola2015-04-1515-51/+19
| | | | | | | | Many of these predate llvm-readobj. With elf-dump we had to match a relocation to symbol number and symbol number to symbol name or section number. llvm-svn: 235015
* Write section and section table entries in the same order.Rafael Espindola2015-04-151-1/+1
| | | | | | We had two different orders, which has no value. llvm-svn: 235004
* Write the section header in the end.Rafael Espindola2015-04-0819-19/+19
| | | | | | | | One could make the argument for writing it immediately after the ELF header, but writing it in the middle of the sections like we were doing just makes it harder for no reason. llvm-svn: 234400
* Use a comma after the unique keyword.Rafael Espindola2015-04-065-7/+12
| | | | | | | | H.J. Lu noted that all .section options are separated by a comma. This patch changes the syntax of unique to require one. llvm-svn: 234174
* Be consistent when deciding if a relocation is needed.Rafael Espindola2015-04-061-0/+10
| | | | | | | | | | | | | | Before when deciding if we needed a relocation in A-B, we wore only checking if A was weak. This fixes the asymmetry. The "InSet" argument should probably be renamed to "ForValue", since InSet is very MachO specific, but doing so in this patch would make it hard to read. This fixes PR22815. llvm-svn: 234165
* Implement unique sections with an unique ID.Rafael Espindola2015-04-044-4/+19
| | | | | | | | | | | This allows the compiler/assembly programmer to switch back to a section. This in turn fixes the bootstrap failure on powerpc (tested on gcc110) without changing the ppc codegen at all. I will try to cleanup the various getELFSection overloads in a followup patch. Just using a default argument now would lead to ambiguities. llvm-svn: 234099
* MC: For variable symbols, maintain MCSymbol::Section as a cache.Peter Collingbourne2015-04-032-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes PR19582. Previously, when an asm assignment (.set or =) was created, we would look up the section immediately in MCSymbol::setVariableValue. This caused symbols to receive the wrong section if the RHS of the assignment had not been seen yet. This had a knock-on effect in the object file emitters, causing them to emit extra symbols, or to give symbols the wrong visibility or the wrong section. For example, in the following asm: .data .Llocal: .text leaq .Llocal1(%rip), %rdi .Llocal1 = .Llocal2 .Llocal2 = .Llocal the first assignment would give .Llocal1 a null section, which would never get fixed up by the second assignment. This would cause the ELF object file emitter to consider .Llocal1 to be an undefined symbol and give it external linkage, even though .Llocal1 should not have been emitted at all in the object file. Or in the following asm: alias_to_local = Ltmp0 Ltmp0: the Mach-O object file emitter would give the alias_to_local symbol a n_type of N_SECT and a n_sect of 0. This is invalid under the Mach-O specification, which requires N_SECT symbols to receive a non-zero section number if the symbol is defined in a section in the object file. https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/#//apple_ref/c/tag/nlist After this change we do not look up the section when the assignment is created, but instead look it up on demand and store it in Section, which is treated as a cache if the symbol is a variable symbol. This change also fixes a bug in MCExpr::FindAssociatedSection. Previously, if we saw a subtraction, we would return the first referenced section, even in cases where we should have been returning the absolute pseudo-section. Now we always return the absolute pseudo-section for expressions that subtract two section-derived expressions. This isn't always correct (e.g. if one of the sections ends up being laid out at an absolute address), but it's probably the best we can do without more context. This allows us to remove code in two places where we appear to have been working around this bug, in MachObjectWriter::markAbsoluteVariableSymbols and in X86AsmPrinter::EmitStartOfAsmFile. Re-applies r233595 (aka D8586), which was reverted in r233898. Differential Revision: http://reviews.llvm.org/D8798 llvm-svn: 233995
* Revert r233595, "MC: For variable symbols, maintain MCSymbol::Section as a ↵Peter Collingbourne2015-04-022-17/+0
| | | | | | cache." llvm-svn: 233898
* MC: For variable symbols, maintain MCSymbol::Section as a cache.Peter Collingbourne2015-03-302-0/+17
| | | | | | | | | | | This fixes the visibility of symbols in certain edge cases involving aliases with multiple levels of indirection. Fixes PR19582. Differential Revision: http://reviews.llvm.org/D8586 llvm-svn: 233595
* Don't be over eager in evaluating a subtraction with a weak symbol.Rafael Espindola2015-03-241-0/+12
| | | | | | | In a subtraction of the form A - B, if B is weak, there is no way to represent that on ELF since all relocations add the value of a symbol. llvm-svn: 233139
* Reset the CFA offset at the start of every FDE.Rafael Espindola2015-03-241-5/+19
| | | | | | This fixes PR21515. llvm-svn: 233120
* MC: Add more stringent symbol checking to test.Peter Collingbourne2015-03-241-0/+3
| | | | llvm-svn: 233118
* Reorganize the x86 ELF relocation selection logic.Rafael Espindola2015-03-202-0/+9
| | | | | | | | | | | | | | | The main differences are: * Split in 32 and 64 bit functions. * First switch on the Modifier so that we have only one non fully covered switch. * Map the fixup kind first to a x86_64 (or i386) specific enum, to make it easy to handle cases like X86::reloc_riprel_4byte_movq_load. * Switch on IsPCRel last, which reduces code duplication. Fixes pr22308. llvm-svn: 232837
* Handle X86::reloc_riprel_4byte in 32 bits mode.Rafael Espindola2015-03-181-0/+4
| | | | | | | | We can get there with .code64. Fixes pr22349. llvm-svn: 232651
* [opaque pointer type] Add textual IR support for explicit type parameter to ↵David Blaikie2015-03-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gep operator Similar to gep (r230786) and load (r230794) changes. Similar migration script can be used to update test cases, which successfully migrated all of LLVM and Polly, but about 4 test cases needed manually changes in Clang. (this script will read the contents of stdin and massage it into stdout - wrap it in the 'apply.sh' script shown in previous commits + xargs to apply it over a large set of test cases) import fileinput import sys import re rep = re.compile(r"(getelementptr(?:\s+inbounds)?\s*\()((<\d*\s+x\s+)?([^@]*?)(|\s*addrspace\(\d+\))\s*\*(?(3)>)\s*)(?=$|%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|zeroinitializer|<|\[\[[a-zA-Z]|\{\{)", re.MULTILINE | re.DOTALL) def conv(match): line = match.group(1) line += match.group(4) line += ", " line += match.group(2) return line line = sys.stdin.read() off = 0 for match in re.finditer(rep, line): sys.stdout.write(line[off:match.start()]) sys.stdout.write(conv(match)) off = match.end() sys.stdout.write(line[off:]) llvm-svn: 232184
* Don't print labels that on ELF are never used.Rafael Espindola2015-03-111-1/+0
| | | | llvm-svn: 231904
* Print section start labels when first switching to the section.Rafael Espindola2015-03-111-0/+2
| | | | | | | This is less brittle and avoids polluting the start of the file with every debug section. llvm-svn: 231898
* Expand variables when evaluating absolute expressions.Rafael Espindola2015-03-041-0/+15
| | | | | | | This allows for variables to be used in .size. This matches gnu AS functionality. llvm-svn: 231295
* [MC][Target] Implement support for R_X86_64_SIZE{32,64}.Davide Italiano2015-03-041-0/+13
| | | | | | | Differential Revision: D7990 Reviewed by: rafael, majnemer llvm-svn: 231216
* DebugInfo: Move new hierarchy into placeDuncan P. N. Exon Smith2015-03-031-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the specialized metadata nodes for the new debug info hierarchy into place, finishing off PR22464. I've done bootstraps (and all that) and I'm confident this commit is NFC as far as DWARF output is concerned. Let me know if I'm wrong :). The code changes are fairly mechanical: - Bumped the "Debug Info Version". - `DIBuilder` now creates the appropriate subclass of `MDNode`. - Subclasses of DIDescriptor now expect to hold their "MD" counterparts (e.g., `DIBasicType` expects `MDBasicType`). - Deleted a ton of dead code in `AsmWriter.cpp` and `DebugInfo.cpp` for printing comments. - Big update to LangRef to describe the nodes in the new hierarchy. Feel free to make it better. Testcase changes are enormous. There's an accompanying clang commit on its way. If you have out-of-tree debug info testcases, I just broke your build. - `upgrade-specialized-nodes.sh` is attached to PR22564. I used it to update all the IR testcases. - Unfortunately I failed to find way to script the updates to CHECK lines, so I updated all of these by hand. This was fairly painful, since the old CHECKs are difficult to reason about. That's one of the benefits of the new hierarchy. This work isn't quite finished, BTW. The `DIDescriptor` subclasses are almost empty wrappers, but not quite: they still have loose casting checks (see the `RETURN_FROM_RAW()` macro). Once they're completely gutted, I'll rename the "MD" classes to "DI" and kill the wrappers. I also expect to make a few schema changes now that it's easier to reason about everything. llvm-svn: 231082
* MC: Allow multiple comma-separated expressions on the .uleb128 directive.Benjamin Kramer2015-02-191-4/+5
| | | | | | | For compatiblity with GNU as. Binutils documents this as '.uleb128 expressions'. Subtle, isn't it? llvm-svn: 229911
* Add testcases I missed in r229541.Rafael Espindola2015-02-171-0/+39
| | | | llvm-svn: 229542
* Revert a series of commits starting at r228886 which is triggering someChandler Carruth2015-02-131-39/+0
| | | | | | | | | | | | | | | | regressions for LLDB on Linux. Rafael indicated on lldb-dev that we should just go ahead and revert these but that he wasn't at a computer. The patches backed out are as follows: r228980: Add support for having multiple sections with the name and ... r228889: Invert the section relocation map. r228888: Use the existing SymbolTableIndex intsead of doing a lookup. r228886: Create the Section -> Rel Section map when it is first needed. These patches look pretty nice to me, so hoping its not too hard to get them re-instated. =D llvm-svn: 229080
* Add support for having multiple sections with the same name and comdat.Rafael Espindola2015-02-121-0/+39
| | | | | | | | Using this in combination with -ffunction-sections allows LLVM to output a .o file with mulitple sections named .text. This saves space by avoiding long unique names of the form .text.<C++ mangled name>. llvm-svn: 228980
* Revert llvm/test/MC/ELF/noexec.s in r227074, "Fix a problem where the ↵NAKAMURA Takumi2015-01-261-1/+0
| | | | | | | | AArch64 ELF assembler was failing with" It should be split into target-specific location. llvm-svn: 227080
* Fix a problem where the AArch64 ELF assembler was failing withEric Christopher2015-01-261-0/+1
| | | | | | | | | -no-exec-stack. This was due to it not deriving from the correct asm info base class and missing the override for the exec stack section query. Added another line to the noexec test line to make sure this doesn't regress. llvm-svn: 227074
OpenPOWER on IntegriCloud