Commit Graph

72 Commits

Author SHA1 Message Date
Ahmed Bougacha
ebb9f17240 Object: Fix Mach-O relocation printing.
There were two problems that made llvm-objdump -r crash:
- for non-scattered relocations, the symbol/section index is actually in the
  (aptly named) symbolnum field.
- sections are 1-indexed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181843 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-14 22:41:29 +00:00
Rafael Espindola
167957fa09 Change getRelocationAdditionalInfo to be ELF only.
It was only implemented for ELF where it collected the Addend, so this
patch also renames it to getRelocationAddend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181502 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-09 03:39:05 +00:00
Rafael Espindola
7098ae2fee Split Alignment out of the Section Characteristics.
The alignment is just a byte in the middle of Characteristics, not an
independent flag. Making it an independent field in the yaml
representation makes it more yamlio friendly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181243 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-06 20:11:21 +00:00
Amara Emerson
1aef163a68 Revert r181009.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181079 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03 23:57:17 +00:00
Amara Emerson
3170ad7dd4 Delete test instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181066 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03 22:39:03 +00:00
Amara Emerson
224e114e71 Temporarily disable failing test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181062 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03 22:27:48 +00:00
Amara Emerson
5d446e61d9 Add support for reading ARM ELF build attributes.
Build attribute sections can now be read if they exist via ELFObjectFile, and
the llvm-readobj tool has been extended with an option to dump this information
if requested. Regression tests are also included which exercise these features.

Also update the docs with a fixed ARM ABI link and a new link to the Addenda
which provides the build attributes specification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181009 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03 11:36:35 +00:00
Rafael Espindola
140536b936 Add missing ':'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180616 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-26 17:54:46 +00:00
Rafael Espindola
956ca7265c Clarify getRelocationAddress x getRelocationOffset a bit.
getRelocationAddress is for dynamic libraries and executables,
getRelocationOffset for relocatable objects.

Mark the getRelocationAddress of COFF and MachO as not implemented yet. Add a
test of ELF's. llvm-readobj -r now prints the same values as readelf -r.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180259 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-25 12:28:45 +00:00
Rafael Espindola
a0840c4b82 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180137 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-23 19:39:34 +00:00
Rafael Espindola
120cf5743b Write relocations in yaml2obj.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180115 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-23 15:53:02 +00:00
Eric Christopher
4f40fa324c Add .ll as a valid test suffix for Object, this allows .ll -> object
and then dumping as tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180010 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-22 10:45:06 +00:00
Rafael Espindola
baecbb82d8 Only run the tests in test/Object/ARM if we have ARM support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179850 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-19 12:47:53 +00:00
Rafael Espindola
db5f927020 Don't read one command past the end.
Thanks to Evgeniy Stepanov for reporting this.

It might be a good idea to add a command iterator abstraction to MachO.h, but
this fixes the bug for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179848 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-19 11:36:47 +00:00
Alexey Samsonov
0eaa6f675c llvm-objdump: Don't print contents of BSS sections: it makes no sense and crashes llvm-objdump on relocated objects with large bss
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179589 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-16 10:53:11 +00:00
Rafael Espindola
aa2163668d Add a test for obj2yaml in preparation for refactoring it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178829 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-05 02:02:05 +00:00
Rafael Espindola
5152e4fb06 Add back parsing of header charactestics.
It had been dropped during the switch to yaml::IO. Also add a test going
from yaml2obj to llvm-readobj. It can be extended as we add more
fields/formats to yaml2obj.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178786 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-04 20:30:52 +00:00
Rafael Espindola
d787a41b11 Implement the "mips endian" for r_info.
Normally r_info is just a 32 of 64 bit number matching the endian of the rest
of the file. Unfortunately, mips 64 bit little endian is special: The top 32
bits are a little endian number and the following 32 are a big endian one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178694 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 21:02:51 +00:00
Eric Christopher
76e70f340c Implements low-level object file format specific output for COFF and
ELF with support for:

- File headers
- Section headers + data
- Relocations
- Symbols
- Unwind data (only COFF/Win64)

The output format follows a few rules:
- Values are almost always output one per line (as elf-dump/coff-dump already do). - Many values are translated to something readable (like enum names), with the raw value in parentheses.
- Hex numbers are output in uppercase, prefixed with "0x".
- Flags are sorted alphabetically.
- Lists and groups are always delimited.

Example output:
---------- snip ----------
Sections [
  Section {
    Index: 1
    Name: .text (5)
    Type: SHT_PROGBITS (0x1)
    Flags [ (0x6)
      SHF_ALLOC (0x2)
      SHF_EXECINSTR (0x4)
    ]
    Address: 0x0
    Offset: 0x40
    Size: 33
    Link: 0
    Info: 0
    AddressAlignment: 16
    EntrySize: 0
    Relocations [
      0x6 R_386_32 .rodata.str1.1 0x0
      0xB R_386_PC32 puts 0x0
      0x12 R_386_32 .rodata.str1.1 0x0
      0x17 R_386_PC32 puts 0x0
    ]
    SectionData (
      0000: 83EC04C7 04240000 0000E8FC FFFFFFC7  |.....$..........|
      0010: 04240600 0000E8FC FFFFFF31 C083C404  |.$.........1....|
      0020: C3                                   |.|
    )
  }
]
---------- snip ----------

Relocations and symbols can be output standalone or together with the section header as displayed in the example.
This feature set supports all tests in test/MC/COFF and test/MC/ELF (and I suspect all additional tests using elf-dump), making elf-dump and coff-dump deprecated.

Patch by Nico Rieck!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 18:31:38 +00:00
Eric Christopher
19d7322170 Implement sectionContainsSymbol for ELF.
Patch by Nico Rieck!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178677 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 18:31:19 +00:00
Eric Christopher
eac49f668a When dumping clear the arm/thumb flag for now.
Patch by Nico Rieck!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178676 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 18:31:12 +00:00
Shankar Easwaran
bd1737c846 [tools][llvm-readobj] print the name of the section when iterating the symbol table / dynamic symbol table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177873 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-25 16:06:51 +00:00
Michael J. Spencer
d326d05fb9 [llvm-readobj] Add ELF .dynamic table dumping.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175592 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20 02:37:12 +00:00
Michael J. Spencer
def0c1f756 [Object][ELF] Fix crash on no dynamic section.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174639 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-07 18:26:45 +00:00
Michael J. Spencer
27b2b1b4e5 [llvm-objdump] Emit addresses with the correct number of leading 0's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172130 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-10 22:40:50 +00:00
Michael J. Spencer
95abfbe8e9 [Object][ELF] Fix incorrect size of members for the 64 version of Elf_Phdr_Impl.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171650 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-06 03:57:11 +00:00
Michael J. Spencer
b2c064c695 [objdump] Add --private-headers, -p.
This currently prints the ELF program headers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171649 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-06 03:56:49 +00:00
Michael J. Spencer
4d9c5397b4 [Object][ELF] Add a maximum alignment. This is used by createELFObjectFile to create a properly aligned reader.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171520 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-04 20:36:28 +00:00
Michael J. Spencer
3fea4ef0b4 [Object] Temporarily disable these tests.
They are failing because archives create unaligned ELF files. The recent
Endian change added a __builtin_unreachable() when this happens. I will be
committing a fix for this soon.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171438 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-03 01:24:32 +00:00
Rafael Espindola
5b712efd9a Fix bits check in ELFObjectFile::isSectionZeroInit().
Fixes PR14723.

Patch by Sami Liedes!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171309 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 18:20:51 +00:00
Rafael Espindola
fc73847d8f Dump sections. Extracted from a patch by Sami Liedes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171304 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 16:29:44 +00:00
Rafael Espindola
148ee4f224 Print a header above the symbols. Extracted from a patch by Sami Liedes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171302 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-31 16:05:21 +00:00
Tim Northover
1c2b2f9c56 Teach MachO which sections contain code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170349 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-17 17:59:32 +00:00
Shankar Easwaran
a8028e5884 numerically sort the symbols, so that the testcase result is uniform
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167872 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 21:01:11 +00:00
Daniel Dunbar
ed074e9a1b llvm-nm: Make sort more stable when symbol names are equal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167866 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 19:39:55 +00:00
Shankar Easwaran
206252cc9f Adding changes to support GNU style archive library reading
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167853 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 18:38:42 +00:00
Alexey Samsonov
01fa41a106 Fix SymbolRef::getAddress implementation for ELF. The 'value' field in symbol table entry should be treated differently for relocatable and relocated files. This patch fixes symbol addresses printed by llvm-nm for executables and shared objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164365 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 07:08:08 +00:00
Nick Lewycky
0c09e76e52 Add missing file for test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163272 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05 23:52:20 +00:00
Nick Lewycky
033d182589 Teach libObject about some more ELF relocations. llvm-objdump -r now knows
every relocation in C++ hello world built with debug info.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163271 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05 23:48:54 +00:00
NAKAMURA Takumi
68990df1f9 Create llvm/test/Object/Mips/lit.local.cfg to check Mips in targets_to_build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162819 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-29 01:37:57 +00:00
Jack Carter
f05da8ebd6 Moved input for objdump test from Mips to Inputs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162808 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-29 00:10:48 +00:00
Jack Carter
fd6d165155 Some of the instructions in the Mips instruction set are revision
delimited. llvm-mc -disassemble access these through the -mattr
option.

llvm-objdump -disassemble had no such way to set the attribute so
some instructions were just not recognized for disassembly.

This patch accepts llvm-mc mechanism for specifying the attributes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162781 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-28 19:24:49 +00:00
Matt Beaumont-Gay
923123c370 Move test yaml files under Inputs until they are converted to be the actual
test files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161219 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 21:52:49 +00:00
Michael J. Spencer
a915f247f7 Add yaml2obj. A utility to convert YAML to binaries.
yaml2obj takes a textual description of an object file in YAML format
and outputs the binary equivalent. This greatly simplifies writing
tests that take binary object files as input.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161205 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 19:16:56 +00:00
Marshall Clow
50b4c52633 Add relocation types for Hexagon processor; patch by Sidney Manning <sidneym@codeaurora.org>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159081 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-23 14:46:18 +00:00
Eli Bendersky
cc85160672 Continue cleanup of LIT, getting rid of the remaining artifacts from dejagnu
* Removed test/lib/llvm.exp - it is no longer needed 
* Deleted the dg.exp reading code from test/lit.cfg. There are no dg.exp files
  left in the test suite so this code is no longer required. test/lit.cfg is
  now much shorter and clearer 
* Removed a lot of duplicate code in lit.local.cfg files that need access to
  the root configuration, by adding a "root" attribute to the TestingConfig
  object. This attribute is dynamically computed to provide the same
  information as was previously provided by the custom getRoot functions. 
* Documented the config.root attribute in docs/CommandGuide/lit.pod





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153408 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-25 09:02:19 +00:00
David Meyer
2d70e263c2 Support reading GNU symbol versions in ELFObjectFile
* Add enums and structures for GNU version information.
* Implement extraction of that information on a per-symbol basis (ELFObjectFile::getSymbolVersion).
* Implement a generic interface, GetELFSymbolVersion(), for getting the symbol version from the ObjectFile (hides the templating).
* Have llvm-readobj print out the version, when available.
* Add a test for the new feature: readobj-elf-versioning.test



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152436 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 20:59:52 +00:00
David Meyer
97f7787bfb [Object]
Add ObjectFile::getLoadName() for retrieving the soname/installname of a shared object.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151845 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-01 22:19:54 +00:00
David Meyer
5c2b4ea73c [Object]
* Add begin_dynamic_table() / end_dynamic_table() private interface to ELFObjectFile.
* Add begin_libraries_needed() / end_libraries_needed() interface to ObjectFile, for grabbing the list of needed libraries for a shared object or dynamic executable.
* Implement this new interface completely for ELF, leave stubs for COFF and MachO.
* Add 'llvm-readobj' tool for dumping ObjectFile information.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151785 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-01 01:36:50 +00:00
Michael J. Spencer
dfa1896b6b [Object] Add {begin,end}_dynamic_symbols stubs and implementation for ELF.
Add -D option to llvm-nm to dump dynamic symbols.

Patch by David Meyer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151600 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-28 00:40:37 +00:00