summaryrefslogtreecommitdiffstats
path: root/llvm/test/MC/ELF/alias.s
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-readobj] Change -t to --symbols in tests. NFCFangrui Song2019-05-011-1/+1
| | | | | | | | | | -t is --symbols in llvm-readobj but --section-details (unimplemented) in readelf. The confusing option should not be used since we aim for improving compatibility. Keep just one llvm-readobj -t use case in test/tools/llvm-readobj/symbols.test llvm-svn: 359661
* [llvm-readobj] Display section names for STT_SECTION symbols.Matt Davis2019-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch will obtain the section name for symbols that refer to a section. Prior to this patch the Name field for STT_SECTIONs was blank, now it is populated. Before: ``` Symbol table '.symtab' contains 6 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _GLOBAL_OFFSET_TABLE_ 5: 0000000000000000 0 TLS GLOBAL DEFAULT UND sym ``` With this patch: ``` Symbol table '.symtab' contains 6 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 .data 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .bss 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _GLOBAL_OFFSET_TABLE_ 5: 0000000000000000 0 TLS GLOBAL DEFAULT UND sym ``` This fixes PR40788 Reviewers: jhenderson, rupprecht, espindola Reviewed By: rupprecht Subscribers: emaste, javed.absar, arichardson, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58796 llvm-svn: 355207
* Omit unused section symbols from the symbol table.Rafael Espindola2015-06-041-8/+0
| | | | | | | | | | | | | | 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-031-3/+3
| | | | | | | | | | | | | | 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-281-4/+4
| | | | | | | | | 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
* MC: For variable symbols, maintain MCSymbol::Section as a cache.Peter Collingbourne2015-04-031-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-021-9/+0
| | | | | | cache." llvm-svn: 233898
* MC: For variable symbols, maintain MCSymbol::Section as a cache.Peter Collingbourne2015-03-301-0/+9
| | | | | | | | | | | 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
* MC: Add more stringent symbol checking to test.Peter Collingbourne2015-03-241-0/+3
| | | | llvm-svn: 233118
* MC: Label definitions are permitted after .set directivesDavid Majnemer2014-12-241-0/+13
| | | | | | | | | .set directives may be overridden by other .set directives as well as label definitions. This fixes PR22019. llvm-svn: 224811
* Teach llvm-readobj to print human friendly description of reserved sections.Rafael Espindola2014-03-241-2/+2
| | | | llvm-svn: 204584
* Make the test harder by using a non-zero offset.Rafael Espindola2014-03-191-7/+7
| | | | llvm-svn: 204205
* Revert r203962 and two revisions depending on it: r204028 and r204059.Alexander Kornienko2014-03-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The revision I'm reverting breaks handling of transitive aliases. This blocks us and breaks sanitizer bootstrap: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/2651 (and checked locally by Alexey). This revision is the result of: svn merge -r204059:204058 -r204028:204027 -r203962:203961 . + the regression test added to test/MC/ELF/alias.s Another way to reproduce the regression with clang: $ cat q.c void a1(); void a2() __attribute__((alias("a1"))); void a3() __attribute__((alias("a2"))); void a1() {} $ ~/work/llvm-build/bin/clang-3.5-good -c q.c && mv q.o good.o && \ ~/work/llvm-build/bin/clang-3.5-bad -c q.c && mv q.o bad.o && \ objdump -t good.o bad.o good.o: file format elf64-x86-64 SYMBOL TABLE: 0000000000000000 l df *ABS* 0000000000000000 q.c 0000000000000000 l d .text 0000000000000000 .text 0000000000000000 l d .data 0000000000000000 .data 0000000000000000 l d .bss 0000000000000000 .bss 0000000000000000 l d .comment 0000000000000000 .comment 0000000000000000 l d .note.GNU-stack 0000000000000000 .note.GNU-stack 0000000000000000 l d .eh_frame 0000000000000000 .eh_frame 0000000000000000 g F .text 0000000000000006 a1 0000000000000000 g F .text 0000000000000006 a2 0000000000000000 g F .text 0000000000000006 a3 bad.o: file format elf64-x86-64 SYMBOL TABLE: 0000000000000000 l df *ABS* 0000000000000000 q.c 0000000000000000 l d .text 0000000000000000 .text 0000000000000000 l d .data 0000000000000000 .data 0000000000000000 l d .bss 0000000000000000 .bss 0000000000000000 l d .comment 0000000000000000 .comment 0000000000000000 l d .note.GNU-stack 0000000000000000 .note.GNU-stack 0000000000000000 l d .eh_frame 0000000000000000 .eh_frame 0000000000000000 g F .text 0000000000000006 a1 0000000000000000 g F .text 0000000000000006 a2 0000000000000000 g .text 0000000000000000 a3 llvm-svn: 204137
* Don't hide the first ELF symbol.Rafael Espindola2013-06-051-0/+9
| | | | | | | | The first symbol on ELF is dummy, but it has a defined content and readelf normally displays it. With this change llvm-readobj also displays it and we can check that llvm-mc output is correct according to the standard. llvm-svn: 183337
* Replace coff-/elf-dump with llvm-readobjNico Rieck2013-04-121-68/+76
| | | | llvm-svn: 179361
* print st_shndx with the correct number of bits.Rafael Espindola2011-08-041-7/+7
| | | | llvm-svn: 136880
* print st_other with the correct number of bits.Rafael Espindola2011-08-041-7/+7
| | | | llvm-svn: 136877
* print st_type with the correct number of bits.Rafael Espindola2011-08-041-7/+7
| | | | llvm-svn: 136875
* Print st_bind with the correct number of bits.Rafael Espindola2011-08-041-7/+7
| | | | llvm-svn: 136874
* Another counter goes decimal.Rafael Espindola2011-08-041-10/+10
| | | | llvm-svn: 136871
* Print all 64bits for st_value and st_size. Adjust tests accordingly.Roman Divacky2010-12-201-14/+14
| | | | llvm-svn: 122263
* Be more strict on when we produce an undefined reference. In gas a file withRafael Espindola2010-10-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | just .type foo,@object will produce an undefined reference to foo. On the other hand, a file with just .weakref bar, foo will not. It is somewhat hard to support both in MC since both statements should create the symbols. It should be possible if we really need to by adding to the flags, but hopefully that is not necessary. With this patch we do not produce a undefined reference in any of those cases. The assembly file needs an actual use for the undefined reference to be present. This is in preparation for a patch implementing .weakref. llvm-svn: 117735
* Fixing r116753 r116756 r116777Jason W Kim2010-10-191-62/+62
| | | | | | | | | | | | | | | | | | | The failures in r116753 r116756 were caused by a python issue - Python likes to append 'L' suffix to stringified numbers if the number is larger than a machine int. Unfortunately, this causes a divergence of behavior between 32 and 64 bit python versions. I re-crafted elf-dump/common_dump to take care of these issues by: 1. always printing 0x (makes for easy sed/regex) 2. always print fixed length (exactly 2 + numBits/4 digits long) by mod ((2^numBits) - 1) 3. left-padded with '0' There is a residual common routine that is also used by macho-dump (dataToHex) , so I left the 'section_data' test values alone. llvm-svn: 116823
* Speculatively revert 116753 and 116756 to attempt to fix the bots.Eric Christopher2010-10-191-62/+62
| | | | llvm-svn: 116777
* Changed elf-dump to output hex format by default.Jason W Kim2010-10-181-62/+62
| | | | | | Also updated tests. llvm-svn: 116753
* Refactor code a bit and avoid creating unnecessary entries in the stringRafael Espindola2010-10-151-5/+5
| | | | | | map. llvm-svn: 116579
* Remove some code duplication.Rafael Espindola2010-10-141-5/+5
| | | | llvm-svn: 116484
* Get binding and visibility info from the the alias, but Type from the symbolRafael Espindola2010-10-061-9/+34
| | | | | | being aliased. llvm-svn: 115836
* Implement more alias cases.Rafael Espindola2010-10-051-0/+37
| | | | llvm-svn: 115699
* Implement a simple alias case and refactor the code a bit so that theRafael Espindola2010-10-051-0/+22
isInSymtab and isLocal logic in the two loops don't get easily out of sync. llvm-svn: 115643
OpenPOWER on IntegriCloud