Commit Graph

389 Commits

Author SHA1 Message Date
Rafael Espindola
96052a8d12 Add support for inline asm symbols in llvm-ar.
This should allow llvm-ar to be used instead of gnu ar + plugin in a LTO
build. I will add a release note about it once I finish a LTO bootstrap with it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212287 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 19:40:08 +00:00
Rafael Espindola
0a7a2ef6b5 Add support for inline asm symbols to IRObjectFile.
This also enables it in llvm-nm so that it can be tested.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212282 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 18:59:23 +00:00
Kevin Enderby
c150516f36 Add the -U flag to llvm-nm as an alias to -defined-only
as darwin’s nm(1) uses -U for this functionality.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212280 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 18:18:50 +00:00
Kevin Enderby
1faddea960 Add the -reverse-sort flag (aka -r) to llvm-nm
which exists in other Unix nm(1)’s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212235 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-02 23:23:58 +00:00
Kevin Enderby
adaa88ecc5 Add the -arch flag support to llvm-size like what was done to llvm-nm
to select the slice out of a Mach-O universal file.  This also includes
support for -arch all, selecting the host architecture by default from
a universal file and checking if -arch is used with a standard Mach-O
it matches that architecture.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212108 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-01 17:19:10 +00:00
Ed Maste
816d9c7b72 objdump: Add test for ELF file with no section table
This is a test for the fix in r211904.

Differential Revision: http://reviews.llvm.org/D4349


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212059 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30 20:03:02 +00:00
Kevin Enderby
c28eff1356 Add the -arch flag support to llvm-nm to select the slice out of a Mach-O
universal file.  This also includes support for -arch all, selecting the host
architecture by default from a universal file and checking if -arch is used
with a standard Mach-O it matches that architecture.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212054 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30 18:45:23 +00:00
Simon Atanasyan
fc9897f66f [ELF][Mips] Fix recognition of MIPS 64-bit arch in the ELFObjectFile:getArch() method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211891 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 11:36:45 +00:00
NAKAMURA Takumi
63a0ff93c0 nm-trivial-object.test requires shell since Lit internal runner isn't capable of chdir.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211537 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 21:07:04 +00:00
Kevin Enderby
138222e56f Change the default input for llvm-nm to be a.out instead of standard input
to match llvm-size and other UNIX systems for their nm(1).

Tweak test cases that used llvm-nm with standard input to add a "-" to
indicate that and add a test case to check the default of a.out for llvm-nm.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211529 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 20:27:53 +00:00
Kevin Enderby
efc447827d Fix some double printing of filenames for archives in llvm-nm when
the tool is given multiple files.  Also fix the same issue with Mach-O
universal files. And fix the newline spacing to separate the output
in these cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211405 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 21:29:27 +00:00
Kevin Enderby
d1e64617ee Added the -m option as an alias for -format=darwin to llvm-nm and llvm-size
which is what the darwin tools use for the Mach-O format output.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211326 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 00:04:16 +00:00
Kevin Enderby
f7b992bdcd Fix the output of llvm-nm for Mach-O files to use the characters ‘d’ and ‘b’ for
data and bss symbols instead of the generic ’s’ for a symbol in a section.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211321 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 22:49:21 +00:00
Kevin Enderby
c28016e413 Change the output of llvm-nm and llvm-size for Mach-O universal files (aka
fat files) to print “ (for architecture XYZ)” for fat files with more than
one architecture to be like what the darwin tools do for fat files.

Also clean up the Mach-O printing of archive membernames in llvm-nm to use
the darwin form of "libx.a(foo.o)".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211316 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 22:03:18 +00:00
Kevin Enderby
fb2b9fb894 Teach llvm-size to know about Mach-O universal files (aka fat files) and
fat files containing archives.

Also fix a bug in MachOUniversalBinary::ObjectForArch::ObjectForArch()
where it needed a >= when comparing the Index with the number of
objects in a fat file.  As the index starts at 0.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211230 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18 22:04:40 +00:00
Kevin Enderby
acc5e810aa Add "-format darwin" to llvm-size to be like darwin's size(1) -m output, and
and the -l option for the long format.  Also when the object is a Mach-O
file and the format is berkeley produce output like darwin’s default size(1)
summary berkeley derived output.

Like System V format, there are also some small changes in how and where
the file names and archive member names are printed for darwin and
Mach-O.

Like the changes to llvm-nm these are the first steps in seeing if it is
possible to make llvm-size produce the same output as darwin's size(1).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211117 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-17 17:54:13 +00:00
Rafael Espindola
7f2f94faeb Fix pr17056.
This makes llvm-nm ignore members that are not sufficiently aligned for
lib/Object to handle.

These archives are invalid. GNU AR is able to handle this, but in general
just warns about broken archive members.

We should probably start warning too, but for now just make sure llvm-nm
exits with an 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211036 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-16 16:41:00 +00:00
Rafael Espindola
7acd886ecf Use std::error_code instead of llvm::error_code.
The idea of this patch is to turn llvm/Support/system_error.h into a
transitional header that just brings in the erorr_code api to the llvm
namespace. I will remove it shortly afterwards.

The cases where the general idea needed some tweaking:

* std::errc is a namespace in msvc, so we cannot use "using std::errc". I could
add an #ifdef, but there were not that many uses, so I just added std:: to
them in this patch.

* Template specialization had to be moved to the std namespace in this
patch set already.

* The msvc implementation of default_error_condition doesn't seem to
provide the same transformations as we need. Not too surprising since
the standard doesn't actually say what "equivalent" means. I fixed the
problem by keeping our old mapping and using it at error_code
construction time.

Despite these shortcomings I think this is still a good thing. Some reasons:

* The different implementations of system_error might improve over time.
* It removes 925 lines of code from llvm already.
* It removes 6313 bytes from the text segment of the clang binary when
it is built with gcc and 2816 bytes when building with clang and
libstdc++.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210687 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 19:05:50 +00:00
Alp Toker
8aeca44558 Reduce verbiage of lit.local.cfg files
We can just split targets_to_build in one place and make it immutable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210496 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-09 22:42:55 +00:00
Simon Atanasyan
3c9a2ee891 [yaml2obj][obj2yaml] Support ELF symbol's visibility flags (default/hidden/protected).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210316 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-06 07:41:57 +00:00
Kevin Enderby
ecbc72405e Add "-format darwin" to llvm-nm to be like darwin's nm(1) -m output.
This is a first step in seeing if it is possible to make llvm-nm produce
the same output as darwin's nm(1).  Darwin's default format is bsd but its
-m output prints the longer Mach-O specific details.  For now I added the
"-format darwin" to do this (whos name may need to change in the future).
As there are other Mach-O specific flags to nm(1) which I'm hoping to add some
how in the future.  But I wanted to see if I could get the correct output for
-m flag using llvm-nm and the libObject interfaces.

I got this working but would love to hear what others think about this approach
to getting object/format specific details printed with llvm-nm.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210285 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-05 21:21:57 +00:00
Simon Atanasyan
df96c562a5 [yaml2obj] Add new command line option -docnum.
Input YAML file might contain multiple object file definitions.
New option `-docnum` allows to specify an ordinal number (starting from 1)
of definition used for an object file generation.

Patch reviewed by Sean Silva.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209967 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-31 04:51:07 +00:00
Simon Atanasyan
ce538c7834 [elf2yaml][ELF] Move Info field to the RelocationSection structure. This
field represents ELF section header sh_info field and does not have any
sense for regular sections. Its interpretation depends on section type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209801 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29 11:05:31 +00:00
NAKAMURA Takumi
4ca8b0b66d llvm/test/Object/ar-error.test: Don't check the message "No such file or directory".
It didn't match on non-English version of Windows.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209570 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-24 08:47:11 +00:00
Simon Atanasyan
84a0dc323d [YAML] Add an optional argument EnumMask to the yaml::IO::bitSetCase().
Some bit-set fields used in ELF file headers in fact contain two parts.
The first one is a regular bit-field. The second one is an enumeraion.
For example ELF header `e_flags` for MIPS target might contain the
following values:

Bit-set values:

  EF_MIPS_NOREORDER = 0x00000001
  EF_MIPS_PIC       = 0x00000002
  EF_MIPS_CPIC      = 0x00000004
  EF_MIPS_ABI2      = 0x00000020

Enumeration:

  EF_MIPS_ARCH_32   = 0x50000000
  EF_MIPS_ARCH_64   = 0x60000000
  EF_MIPS_ARCH_32R2 = 0x70000000
  EF_MIPS_ARCH_64R2 = 0x80000000

For printing bit-sets we use the `yaml::IO::bitSetCase()`. It does not
support bit-set/enumeration combinations and prints too many flags from
an enumeration part. This patch fixes this problem. New method
`yaml::IO::maskedBitSetCase()` handle "enumeration" part of bitset
defined by provided mask.

Patch reviewed by Nick Kledzik and Sean Silva.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209504 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-23 08:07:09 +00:00
Filipe Cabecinhas
f97e200a98 llvm-ar: Output the file we errored on.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209500 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-23 05:52:12 +00:00
Kevin Enderby
b38059ab25 Update MachOObjectFile::getSymbolAddress so it returns UnknownAddressOrSize
for undefined symbols, so it matches what COFFObjectFile::getSymbolAddress
does.  This allows llvm-nm to print spaces instead of 0’s for the value
of undefined symbols in Mach-O files.

To make this change other uses of MachOObjectFile::getSymbolAddress
are updated to handle when the Value is returned as UnknownAddressOrSize.
Which is needed to keep two of the ExecutionEngine tests working for example.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209253 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-20 23:04:47 +00:00
Kevin Enderby
95aa960b71 Revert r209235 as it broke two tests:
Failing Tests (2):
	    LLVM :: ExecutionEngine/MCJIT/stubs-sm-pic.ll
	    LLVM :: ExecutionEngine/MCJIT/stubs.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209236 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-20 21:10:15 +00:00
Kevin Enderby
e3f74564ff Update MachOObjectFile::getSymbolAddress so it returns UnknownAddressOrSize
for undefined symbols.  Allowing llvm-nm to print spaces instead of 0’s for
the value of undefined symbols in Mach-O files.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209235 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-20 20:32:18 +00:00
Kevin Enderby
86ad7b70cb Implement MachOObjectFile::isSectionData() and MachOObjectFile::isSectionBSS
so that llvm-size will total up all the sections in the Berkeley format.  This
allows for rough categorizations for Mach-O sections.  And allows the total of
llvm-size’s Berkeley and System V formats to be the same.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209158 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-19 20:36:02 +00:00
Simon Atanasyan
19ab8f850f [yaml2obj][ELF] Add an optional Size field to the YAML section declaration.
Now the only method to configure ELF section's content and size is to assign
a hexadecimal string to the `Content` field. Unfortunately this way is
completely useless when you need to declare a really large section.

To solve this problem this patch adds one more optional field `Size`
to the `RawContentSection` structure. When yaml2obj generates an ELF file
it uses the following algorithm:
1. If both `Content` and `Size` fields are missed create an empty section.
2. If only `Content` field is missed take section length from the `Size`
   field and fill the section by zero.
3. If only `Size` field is missed create a section using data from
   the `Content` field.
4. If both `Content` and `Size` fields are provided validate that the `Size`
   value is not less than size of `Content` data. Than take section length
   from the `Size`, fill beginning of the section by `Content` and the rest
   by zero.

Examples
--------
* Create a section 0x10000 bytes long filled by zero
  Name: .data
  Type: SHT_PROGBITS
  Flags: [ SHF_ALLOC ]
  Size: 0x10000

* Create a section 0x10000 bytes long starting from 'CA' 'FE' 'BA' 'BE'
  Name: .data
  Type: SHT_PROGBITS
  Flags: [ SHF_ALLOC ]
  Content: CAFEBABE
  Size: 0x10000

The patch reviewed by Michael Spencer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208995 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 16:01:00 +00:00
Simon Atanasyan
1564bf7dbe [obj2yaml][ELF] Print relocation's offset as a hex number. Use a proper
types to hold relocation's offset and addend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208906 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15 18:04:09 +00:00
Simon Atanasyan
650c53fe2a [obj2yaml][ELF] Do not print empty Link and Info fields for ELF sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208905 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15 18:04:02 +00:00
Simon Atanasyan
926273d496 [yaml2obj] Add "-o" command line option to specify an output file name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208900 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15 16:14:02 +00:00
Kevin Enderby
14963a696b Teach llvm-nm to know about fat archives (aka MachOUniversal files
containing archives).  First step as other tools will be updated next.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208812 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-14 21:18:50 +00:00
Simon Atanasyan
b8236e532a [obj2yaml] Support ELF input format in the obj2yaml tool.
The ELF header e_flags field in the MIPS related test cases handled
incorrectly. The obj2yaml prints too many flags. I will fix that in the
next patches.

The patch reviewed by Michael Spencer and Sean Silva.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208752 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-14 05:07:47 +00:00
Kevin Enderby
ae417592a5 Fix llvm-nm to print the full 64-bit address for symbols in 64-bit object files.
The implementation might be better to have a method is64Bit() in the class
SymbolicFile instead of having the static routine isSymbolList64Bit() in
llvm-nm.cpp .  But this is very much in the sprit of isObject() and
getNMTypeChar() in llvm-nm.cpp that has a series of if else statements
based on the specific class of the SymbolicFile.  I can update this if
folks would like.

Also the tests were updated to be explicit about checking the address for
64-bits or 32-bits from object files.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208463 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-09 23:57:49 +00:00
Simon Atanasyan
ba148a1b8f [yaml2obj] Follow-up to the r208228 and r208406. Remove duplicated YAML
map keys.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208412 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-09 13:57:33 +00:00
NAKAMURA Takumi
a1e2e91de4 Mark yaml2obj-elf-x86-rel.yaml as XFAIL:vg_leak for now. This has two pairs of duplicate hashes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208406 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-09 11:24:18 +00:00
Simon Atanasyan
d92c843b2e [yaml2obj] Support ELF x86 relocations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208228 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-07 17:06:38 +00:00
Simon Atanasyan
ed37b773e1 [llvm-readobj] Add support for Mips specific ELF header e_flags.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207744 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-01 11:07:19 +00:00
Hans Wennborg
14d1db9019 Use the new StringTableBuilder in yaml2elf
http://reviews.llvm.org/D3574

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207694 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 19:38:09 +00:00
Chandler Carruth
7a36912a9d Update tests to use the new format of printing a TimeValue. It's a bit
odd to have the output of 'llvm-ar tv' depend on the format of
TimeValue::str(), but that's what we have today. If anyone needs the
output to remain compatible with GNU ar or old versions of llvm-ar, just
shout and I'll switch the code to manually format its times.

Note that there isn't a portable format -- Mac and GNU have different
formats at least (thanks Rafael!) so...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207387 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 01:24:32 +00:00
Simon Atanasyan
eb0c9094ac [yaml2obj][ELF] ELF Relocations Support.
The patch implements support for both relocation record formats: Elf_Rel
and Elf_Rela. It is possible to define relocation against symbol only.
Relocations against sections will be implemented later. Now yaml2obj
recognizes X86_64, MIPS and Hexagon relocation types.

Example of relocation section specification:
Sections:
- Name: .text
  Type: SHT_PROGBITS
  Content: "0000000000000000"
  AddressAlign: 16
  Flags: [SHF_ALLOC]

- Name: .rel.text
  Type: SHT_REL
  Info: .text
  AddressAlign: 4
  Relocations:
    - Offset: 0x1
      Symbol: glob1
      Type: R_MIPS_32
    - Offset: 0x2
      Symbol: glob2
      Type: R_MIPS_CALL16

The patch reviewed by Michael Spencer, Sean Silva, Shankar Easwaran.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206017 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-11 04:13:39 +00:00
David Majnemer
878657074a YAMLIO: Allow scalars to dictate quotation rules
Introduce ScalarTraits::mustQuote which determines whether or not a
StringRef needs quoting before it is acceptable to output.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205955 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-10 07:37:33 +00:00
David Majnemer
fb065a1669 Revert "Revert "YAMLIO: Encode ambiguous hex strings explicitly""
Don't quote octal compatible strings if they are only two wide, they
aren't ambiguous.

This reverts commit r205857 which reverted r205857.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205914 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-09 17:04:27 +00:00
David Majnemer
aef1966ed6 obj2yaml: Don't crash if the characteristics field is zero
obj2yaml would fail when seeing a Weak External auxiliary record with a
characteristics field holding zero instead of one of
IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY, IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY,
or IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205911 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-09 16:38:15 +00:00
Filipe Cabecinhas
c657a09ea6 Revert "YAMLIO: Encode ambiguous hex strings explicitly"
This reverts commit r205839.

It broke several tests in lld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205857 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-09 14:35:17 +00:00
David Majnemer
7184f49f40 YAMLIO: Encode ambiguous hex strings explicitly
YAMLIO would turn a BinaryRef into the string 0000000004000000.
However, the leading zero causes parsers to interpret it as being an
octal number instead of a hexadecimal one.

Instead, escape such strings as needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205839 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-09 07:56:27 +00:00
David Majnemer
de6256c938 obj2yaml: Use the correct relocation type for different machine types
The IO normalizer would essentially lump I386 and AMD64 relocations
together.  Relocation types with the same numeric value would then get
mapped in appropriately.

For example:
IMAGE_REL_AMD64_ADDR64 and IMAGE_REL_I386_DIR16 both have a numeric
value of one.  We would see IMAGE_REL_I386_DIR16 in obj2yaml conversions
of object files with a machine type of IMAGE_FILE_MACHINE_AMD64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205746 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-07 23:12:20 +00:00
Rafael Espindola
7df9059541 Implement getRelocationAddress for MachO and ET_REL elf files.
With that, fix the symbolizer to work with any ELF file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205588 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-03 23:54:35 +00:00
Rafael Espindola
ee2bf5b607 Only clear the thumb bit from function addresses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205500 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-03 02:20:43 +00:00
Rafael Espindola
14ae43449c Revert "Fix a nomenclature error in llvm-nm."
This reverts commit r205479.

It turns out that nm does use addresses, it is just that every reasonable
relocatable ELF object has sections with address 0. I have no idea if those
exist in reality, but it at least it shows that llvm-nm should use the name
address.

The added test was includes an unusual .o file with non 0 section addresses. I
created it by hacking ELFObjectWriter.cpp.

Really sorry for the churn.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205493 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-03 00:19:35 +00:00
Daniel Sanders
002ba57eb7 [yaml2obj] Add support for ELF e_flags.
Summary:
The FileHeader mapping now accepts an optional Flags sequence that accepts
the EF_<arch>_<flag> constants. When not given, Flags defaults to zero.

Reviewers: atanasyan

Reviewed By: atanasyan

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3213

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205173 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-31 09:44:05 +00:00
Rafael Espindola
2236f9348d Teach llvm-readobj to print human friendly description of reserved sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204584 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-24 05:00:34 +00:00
David Majnemer
d9a0abcf8f Object: Output .file symbols properly
obj2yaml would emit the NUL bytes padding the auxiliary file symbol
records.  Trimming them looks nicer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204314 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20 06:29:02 +00:00
David Majnemer
6d191534f6 Object: Provide a richer means of describing auxiliary symbols
The current state of affairs has auxiliary symbols described as a big
bag of bytes. This is less than satisfying, it detracts from the YAML
file as being human readable.

Instead, allow for symbols to optionally contain their auxiliary data.
This allows us to have a much higher level way of describing things like
weak symbols, function definitions and section definitions.

This depends on D3105.

Differential Revision: http://llvm-reviews.chandlerc.com/D3092

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204214 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-19 04:47:47 +00:00
Simon Atanasyan
9f685d3951 [yaml2obj][ELF] Assign name (.shstrtab) to the section holds sections names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203897 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-14 06:53:16 +00:00
Rafael Espindola
0ff25b31d8 Now that it is possible, use the mangler in IRObjectFile.
A really simple patch marks the end of a lot of yak shaving :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202463 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 02:17:23 +00:00
Rafael Espindola
91f86b7e1c Add a SymbolicFile interface between Binary and ObjectFile.
This interface allows IRObjectFile to be implemented without having dummy
methods for all section and segment related methods.

Both llvm-ar and llvm-nm are changed to use it. Unfortunately the mangler is
still not plugged in since it requires some refactoring to make a Module hold
a DataLayout.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201881 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-21 20:10:59 +00:00
Rafael Espindola
9e849c7312 Add a test for printing absolute symbols in ELF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200818 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-05 04:36:47 +00:00
Rafael Espindola
7e369ff2e5 Small fix for llvm-nm handling of weak symbols on ELF (print 'v').
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200808 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-04 23:53:15 +00:00
Rafael Espindola
9b06b0fd55 Add a test for common symbols in coff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200803 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-04 23:18:52 +00:00
Rafael Espindola
b81f60fd76 Mark the first dynamic elf symbol as SF_FormatSpecific.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200578 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31 21:40:13 +00:00
Rafael Espindola
6420c11093 Only ELF has a dynamic symbol table. Remove it from ObjectFile.
COFF has only one symbol table.
MachO has a LC_DYSYMTAB, but that is not a symbol table, just extra info about
the one symbol table (LC_SYMTAB).
IR (coming soon) also has only one table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200488 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30 20:45:33 +00:00
Rafael Espindola
8010c98bd5 This has been fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200487 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30 20:29:25 +00:00
Rafael Espindola
b0dcfa5c1f Fix TLS handling in ELF's getAddress and llvm-nm to print 'D' for it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200433 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30 00:42:30 +00:00
Rafael Espindola
c86f56a506 We do use pipefail these days. Update the test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200370 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29 04:08:05 +00:00
Mark Seaborn
2effd6cdc1 Fix "llvm-objdump -d -r" to show relocations inline for ELF files
This fixes a regression introduced by r182908, which broke
llvm-objdump's ability to display relocations inline in a disassembly
dump for ELF object files.

That change removed a SectionRelocMap from Object/ELF.h, which we
recreate in llvm-objdump.cpp.

I discovered this regression via an out-of-tree test
(test/NaCl/X86/pnacl-hides-sandbox-x86-64.ll) which used llvm-objdump.

Note that the "Unknown" string in the test output on i386 isn't quite
right, but this appears to be a pre-existing bug.

Differential Revision: http://llvm-reviews.chandlerc.com/D2559

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200090 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-25 17:38:19 +00:00
Simon Atanasyan
03b94a460d [Object][ELF][Mips] Print symbol name for MIPS ELF relocations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199898 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23 15:05:45 +00:00
Bill Wendling
f847b5bbad Fix typo: : not ;
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199359 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16 07:08:22 +00:00
Rafael Espindola
03f1cb72a4 Make sure we create a new archive by deleting any stale ones first.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199319 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-15 16:56:57 +00:00
Alp Toker
087ab613f4 Correct word hyphenations
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities and contractions in nearby lines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196471 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05 05:44:44 +00:00
NAKAMURA Takumi
6af8781854 llvm-ar: Let opening a directory failed in llvm-ar.
Linux cannot open directories with open(2), although cygwin and *bsd can.

Motivation: The test, Object/directory.ll, had been failing with --target=cygwin on Linux. XFAIL was improper for host issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194257 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-08 12:35:56 +00:00
Rafael Espindola
6152f7d596 Fix llvm-nm to mach OS X's nm on some tests.
There is still a long way to go for llvm-nm, but at least we now match
nm's letter output in the cases we test for.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193912 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-02 05:03:24 +00:00
Rafael Espindola
88e1e103de Create an atom with just the data that failed to disassemble.
Patch by Stephen Checkoway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192827 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-16 19:03:14 +00:00
Simon Atanasyan
c84c742edd [Mips] Teach llvm-readobj to print MIPS-specific ELF program headers.
The patch reviewed by Michael Spencer.
http://llvm-reviews.chandlerc.com/D1846

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192093 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-07 08:58:27 +00:00
Rafael Espindola
aeb0f0cdd2 Add a minimal implementation of ranlib.
This is just enough to get "llvm-ranlib foo.a" working and tested. Making
llvm-ranlib a symbolic link to llvm-ar doesn't work so well with llvm's option
parsing, but ar's option parsing is mostly custom anyway.

This patch also removes the -X32_64 option. Looks like it was just added in
r10297 as part of implementing the current command line parsing. I can add it
back (with a test) if someone really has AIX portability problems without it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189489 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-28 16:22:16 +00:00
Ahmed Bougacha
b2fdd9ee45 MC CFG: Remap enough for data too, analoguous to r188873.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188925 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 19:40:28 +00:00
Ahmed Bougacha
a68512f68f Add testcase for r188873: MCTextAtom boundaries.
Check that they are correctly computed if the last instruction is
larger than 1 byte.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188923 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 19:40:22 +00:00
Ahmed Bougacha
7413b54c89 Add basic YAML MC CFG testcase.
Drive-by llvm-objdump cleanup (don't hardcode ToolName).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188904 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 16:13:25 +00:00
Ahmed Bougacha
9bfc0626c0 MC: ObjectSymbolizer can now recognize external function stubs.
Only implemented in the Mach-O ObjectSymbolizer.
The testcase sadly introduces a new binary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188879 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 07:28:13 +00:00
Daniel Dunbar
24ec2e5a72 [tests] Cleanup initialization of test suffixes.
- Instead of setting the suffixes in a bunch of places, just set one master
   list in the top-level config. We now only modify the suffix list in a few
   suites that have one particular unique suffix (.ml, .mc, .yaml, .td, .py).

 - Aside from removing the need for a bunch of lit.local.cfg files, this enables
   4 tests that were inadvertently being skipped (one in
   Transforms/BranchFolding, a .s file each in DebugInfo/AArch64 and
   CodeGen/PowerPC, and one in CodeGen/SI which is now failing and has been
   XFAILED).

 - This commit also fixes a bunch of config files to use config.root instead of
   older copy-pasted code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188513 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-16 00:37:11 +00:00
Michael J. Spencer
081a1941b5 [Object] Split the ELF interface into 3 parts.
* ELFTypes.h contains template magic for defining types based on endianess, size, and alignment.
* ELFFile.h defines the ELFFile class which provides low level ELF specific access.
* ELFObjectFile.h contains ELFObjectFile which uses ELFFile to implement the ObjectFile interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188022 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-08 22:27:13 +00:00
Rafael Espindola
cf48cf23de Add support for the 's' operation to llvm-ar.
If no other operation is specified, 's' becomes an operation instead of an
modifier. The s operation just creates a symbol table. It is the same as
running ranlib.

We assume the archive was created by a sane ar (like llvm-ar or gnu ar) and
if the symbol table is present, then it is current. We use that to optimize
the most common case: a broken build system that thinks it has to run ranlib.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187353 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-29 12:40:31 +00:00
Rafael Espindola
26b10da9c2 Add an initial implementation of archive symbol table generation.
The symbol table has forward references in the file. Instead of allocating
a temporary buffer or counting the size and then writing, this implementation
writes a dummy value first and patches it once the final value is known.

There is room for performance improvement. I will implement them as soon as I
get some other features (like a ranlib mode) in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186934 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-23 10:47:01 +00:00
Rafael Espindola
30115ec7a3 Mark ELF's first symbol as format specific so that llvm-nm ignores it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186860 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-22 19:24:34 +00:00
Rafael Espindola
51392a079e Replace archive members in the old position.
This matches gnu archive behavior and since archive member order can change
which member is used, not changing the order on replacement looks like the
right thing to do.

This patch also refactors the logic for which archive member to keep and
whether to move it to a helper function (computeInsertAction). The
nesting in computeNewArchiveMembers was getting a bit confusing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186829 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-22 15:11:51 +00:00
Rafael Espindola
bb8234b7ff Don't depend on a llvm-ar specific behavior.
GNU ar when not given the a or b modifiers replaces archive members in the
same location of the old ones. I am about to implement that in llvm-ar. For
now, just don't depend on the current llvm-ar behavior on this test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186823 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-22 12:41:04 +00:00
Rafael Espindola
02a1364bf8 Handle replacement into a position past the original member.
We were incorrectly computing where to insert a member if it was replacing
a previous member that was before the insert point.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186792 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-21 12:58:07 +00:00
Rafael Espindola
b55dcfe47f Fix inserting new elements in a specified location.
We were only handling the 'a' and 'b' options during moves before.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186721 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-19 21:23:28 +00:00
Rafael Espindola
b1a003f377 Split openFileForWrite into windows and unix versions.
It is similar to 186511, but for creating files for writing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-19 15:02:03 +00:00
Rafael Espindola
b0aa9e9718 Split openFileForRead into Windows and Unix versions.
This has some advantages:

* Lets us use native, utf16 windows functions.
* Easy to produce good errors on windows about trying to use a
directory when we want a file.
* Simplifies the unix version a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186511 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-17 14:58:25 +00:00
NAKAMURA Takumi
f7e73accb7 raw_ostream.cpp: Introduce <fcntl.h> to let O_BINARY provided. Or, llvm::outs() would be set to O_TEXT by default.
llvm/test/Object/check_binary_output.ll is expected to pass on win32.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186480 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-17 02:21:10 +00:00
NAKAMURA Takumi
45193d39d9 llvm/test/Object/ar-create.test: Relax a CHECK line to satisfy localized message catalogue.
For example, 'No such file or directory' cannot be seen on Japanese version of msvcrt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186469 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 23:17:22 +00:00
NAKAMURA Takumi
7432572c3c llvm/test/Object/check_binary_output.ll: Mark it as XFAIL on Windows. Investigating.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186468 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 23:16:57 +00:00
Rafael Espindola
95779b65cf On error, close the temporary file descriptor.
With this change llvm-ar can remove the temporary file on windows too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186423 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 16:00:32 +00:00
NAKAMURA Takumi
1cf95914b7 llvm/test/Object/directory.ll: Mark it as XFAIL:cygwin. Directories can be opened on cygwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186387 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 09:06:47 +00:00
NAKAMURA Takumi
ff8f9e58ec Fix TimeValue::toWin32Time() to be symmetric to fromWin32Time() and compatible to Win32's FILETIME.
llvm-ar is the only user of toWin32Time() (via setLastModificationAndAccessTime), and r186298 can be reverted.
It had been buggy since the initial commit.

FIXME: Could we rename {from|to}Win32Time as {from|to}Win32FILETIME in TimeValue?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186374 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 02:43:51 +00:00
Rafael Espindola
311dbb8efe Add mingw32 to the XFAIL. I forgot about it when adding win32.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186365 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 23:51:47 +00:00
Rafael Espindola
086dfda034 XFAIL on windows too and document the XFAILs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186354 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 22:16:53 +00:00
Rafael Espindola
4c275c31aa XFAIL this on freebsd to bring the bot back.
Joerg Sonnenberger tells me one can open a directory in freebsd. I will try
to centralize our calls to open so that we can handle O_BINARY in one place,
and will then handle this there too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186317 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 12:18:30 +00:00
NAKAMURA Takumi
d8fdb628ea Mark llvm/test/Object/extract.ll as XFAIL:mingw32, for now.
FIXME: Investigate Win32's TimeValue stuff!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186298 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 03:04:13 +00:00
Chandler Carruth
3c0e8fbd4e The archive update test has a subtle race condition in it: if the test
is executed within the same second as the inputs for the test are
checked out from the source tree, it will fail to update due to being
below the resolution of the 'mtime' test used.

Now, this may seem improbably to you... ok, maybe *really* improbable,
but consider a system which does distributed execution of tests by
shipping their inputs to another machine and runs them. That might cause
the mtime to be quite recent during the test run. ;]

Instead, create two files directly in the test (allowing all platforms
to see the problem) and add either a use of the 'touch' command that
forces one mtime to some time quite a bit in the past, or it sleeps for
just over a second to be outside of the precision window.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186282 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-14 10:46:51 +00:00
Benjamin Kramer
b666fd553d Only verify the length in archive test, we can't make assumptions on the spacing.
And .* did just match about anything anyways.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186246 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-13 15:21:39 +00:00
Rafael Espindola
c951651894 Add r186216 back, but make the test tolerant of different uids and gids.
original message:
Fix a off by one error about which members need to use the string table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186238 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-13 04:14:13 +00:00
Chandler Carruth
1dedabdfad Revert commit r186216 -- it's breaking bots:
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/6897/steps/check-all/logs/LLVM%3A%3Aarchive-format.test

Original commit log:
  Fix a off by one error about which members need to use the string
  table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186232 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-13 00:42:56 +00:00
Rafael Espindola
6383ef98fa Fix a off by one error about which members need to use the string table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186216 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 22:22:34 +00:00
Rafael Espindola
0878d701cb Change archive-update.test to create a new file on the fly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186206 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 21:17:17 +00:00
Rafael Espindola
17d8c751ae Rename directory to avoid problems on windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186202 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 20:53:23 +00:00
Rafael Espindola
34ac52d937 Change llvm-ar to use lib/Object.
This fixes two bugs is lib/Object that the use in llvm-ar found:
* In OS X created archives, the name can be padded with nulls. Strip them.
* In the constructor, remember the first non special member and use that in
  begin_children. This makes sure we skip all special members, not just the
  first one.

The change to llvm-ar itself consist of
* Using lib/Object for reading archives instead of ArchiveReader.cpp.
* Writing the modified archive directly, instead of creating an in memory
  representation.

The old Archive library was way more general than what is needed, as can
be seen by the diffstat of this patch.

Having llvm-ar using lib/Object now opens the way for creating regular symbol
tables for both native objects and bitcode files so that we can use those
archives for LTO.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186197 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 20:21:39 +00:00
Rafael Espindola
94803598aa Add a test for llvm-ar's u option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186192 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 19:34:24 +00:00
Rafael Espindola
ec11706155 Relax the test a bit more to handle different UIDs and GIDs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186186 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 19:13:16 +00:00
Rafael Espindola
f671ab89a5 Relax test a bit to handle umask differences.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186184 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 18:54:28 +00:00
Rafael Espindola
8f81325efc Add a test for the 'o' option in llvm-ar.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186183 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 18:51:25 +00:00
Rafael Espindola
5e102c6c48 Don't reject an empty archive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186159 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 13:32:28 +00:00
NAKAMURA Takumi
6ebd77a6c3 llvm/test/Object/archive-toc.test: Use env(1) to satisfy win32 hosts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186143 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-12 02:34:45 +00:00
Rafael Espindola
1051934164 Add tests for the before and after modifiers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186118 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 21:11:55 +00:00
Rafael Espindola
3a942ac858 Add a test for llvm-ar's m operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186110 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 19:09:04 +00:00
Rafael Espindola
71857ccdb8 Fix a FIXME about the format and add a test.
While at it, use strftime on Unix too and use the thread safe versions
of localtime.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186090 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 15:35:23 +00:00
Rafael Espindola
12fa02841c Merge these tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186084 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 13:44:10 +00:00
Rafael Espindola
aad52dfef9 Use a more unique name to avoid conflicting with directory.ll tests when running
in parallel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186083 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 13:31:38 +00:00
Rafael Espindola
fc699872e3 Add a test for llvm-ar's 'd' operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186082 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 13:24:27 +00:00
Rafael Espindola
86779ee177 Add tests for the 'x' operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186081 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 13:13:09 +00:00
Rafael Espindola
b0d599334f Remove this test for now.
It is not reliable to depend on the output of llvm_unreachable. The original
change will have proper tests when llvm-ar moves to lib/Object (soon).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186043 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-10 22:15:29 +00:00
Rafael Espindola
a739759fca Find the symbol table on archives created on OS X.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186041 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-10 22:07:59 +00:00
Rafael Espindola
6911911e61 Move tests from test/Archive to test/Object.
There is no lib/Archive anymore and some archive tests were in test/Archive and
others in test/Object. Since archive is just one of the formats supported by
lib/Object, test/Object is probably the best location.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186038 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-10 21:47:16 +00:00
Rafael Espindola
5159718095 Don't crash in 'llvm -s' when an archive has no symtab.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186029 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-10 20:14:22 +00:00
Rafael Espindola
61de142984 Don't create an archive if, for example, we are asked to print the index.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185697 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-05 13:03:07 +00:00
Rafael Espindola
6d88f9b73a Add support for archives with no symbol table or string table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185664 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-04 19:40:23 +00:00
Rafael Espindola
09a7f6016a Add support for gnu archives with a string table and no symtab.
While there, use early returns to reduce nesting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185547 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-03 15:57:14 +00:00
Rafael Espindola
40d40dd44e Make llvm-nm return 1 on error.
This is a small compatibility improvement with gnu nm and makes llvm-nm more
useful as a testing tool.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185546 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-03 15:46:03 +00:00
Sean Silva
068463b714 [yaml2obj][ELF] Make symbol table top-level key.
Although in reality the symbol table in ELF resides in a section, the
standard requires that there be no more than one SHT_SYMTAB. To enforce
this constraint, it is cleaner to group all the symbols under a
top-level `Symbols` key on the object file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184627 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-22 01:38:00 +00:00
Sean Silva
6f0ca0c590 This was a nifty test, but remove it.
It wouldn't really test anything that doesn't already have a more
targeted test:
`yaml2obj-elf-section-basic.yaml`:
  Already tests that section content is correctly passed though.
`yaml2obj-elf-symbol-basic.yaml` (this file):
  Tests that the st_value and st_size attributes of `main` are set
  correctly.
Between those two tests, disassembling the file doesn't really add
anything, so just remove mention of disassembling the file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184607 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21 23:17:13 +00:00
Sean Silva
8fa38898ff Revert "Put r184469 disassembler test back on X86"
This reverts commit r184602. In an upcoming commit, I will just remove
the disassembler part of the test; it was mostly just a "nifty" thing
marking a milestone but it doesn't test anything that isn't tested
elsewhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184606 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21 23:17:10 +00:00
Renato Golin
b37e50b660 Put r184469 disassembler test back on X86
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184602 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21 22:42:20 +00:00
Sean Silva
a622a3f450 [yaml2obj][ELF] Don't do disassembly in this test.
This was causing buildbot failures when build without X86 support.

Is there a way to conditionalize the test on the X86 target being
present?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184597 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21 21:51:15 +00:00
Sean Silva
326c193e0a [yaml2obj][ELF] Allow expressing undefined symbols.
Previously we unconditionally enforced that section references in
symbols in the YAML had a name that was a section name present in the
object, and linked the references to that section. Now, permit empty
section names (already the default, if the `Section` key is not
provided) to indicate SHN_UNDEF.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184513 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21 01:11:48 +00:00
Sean Silva
4235ba32f2 [yaml2obj][ELF] Don't explicitly set Binding with STB_*
Instead, just have 3 sub-lists, one for each of
{STB_LOCAL,STB_GLOBAL,STB_WEAK}.

This allows us to be a lot more explicit w.r.t. the symbol ordering in
the object file, because if we allowed explicitly setting the STB_*
`Binding` key for the symbol, then we might have ended up having to
shuffle STB_LOCAL symbols to the front of the list, which is likely to
cause confusion and potential for error.

Also, this new approach is simpler ;)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184506 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21 00:27:50 +00:00
Sean Silva
e38f640b22 [yaml2obj][ELF] Add support for st_value and st_size.
After this patch, the ELF file produced by
`yaml2obj-elf-symbol-basic.yaml`, when linked and executed on x86_64
(under SysV ABI, obviously; I tested on Linux), produces a working
executable that goes into an infinite loop!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184469 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-20 20:59:47 +00:00
Sean Silva
6525e92b32 [yaml2obj][ELF] Allow symbols to reference sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184468 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-20 20:59:41 +00:00
Rafael Espindola
440dfe9644 Make sure ar is creating a new file instead of updating an existing one.
Should fix the bots that are seeing a corrupted file from a previous run.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184424 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-20 13:44:49 +00:00
Sean Silva
6e6259d105 [yaml2obj][ELF] Beef up this test a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184269 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-19 00:55:32 +00:00
Sean Silva
ea94e114b4 [yaml2obj][ELF] Support ELFOSABI_* enum.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184268 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-19 00:55:28 +00:00
Sean Silva
5ba1225fb0 [yaml2obj][ELF] Support st_info through Binding and Type YAML keys.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184263 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-19 00:11:59 +00:00
Sean Silva
ca0170ffa1 [yaml2obj][ELF] Ensure STN_UNDEF entry is present.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184258 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 23:19:17 +00:00
Sean Silva
afcf60fe15 [yaml2obj][ELF] Rudimentary symbol table support.
Currently, we only output the name.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184255 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 23:14:03 +00:00
Alexey Samsonov
9c22f87b13 Basic support for parsing Mach-O universal binaries in LLVMObject library
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184191 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 15:03:28 +00:00
Sean Silva
fe57e347a5 [yaml2obj] Add support for sh_link via Link key.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184022 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-15 00:25:26 +00:00
Sean Silva
97d37e8181 [yaml2obj] Add support for sh_addralign via AddressAlign key.
For consistency, change the address in the test case from 0xDEADBEEF to
0xCAFEBABE since 0xCAFEBABE that actually has a 2-byte alignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183962 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-14 00:38:02 +00:00
Sean Silva
2a7e79a30f [yaml2obj] Add support for specifying raw section content.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183955 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-13 22:20:01 +00:00
Sean Silva
45b812d1a7 [yaml2obj] Add sh_addr via Address key.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183954 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-13 22:19:54 +00:00
Sean Silva
274264ce2b [yaml2obj] Initial ELF section support.
The current functionality is extremely basic and a bit rough around the
edges, but it will flesh out in future commits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183953 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-13 22:19:48 +00:00
Sean Silva
0d3b9ac634 [yaml2obj] Remove fragile test case.
This test case was a "sanity check"/"breathing" test case at first, but
is really fragile, which impairs changes to yaml2obj.

`test/Object/yaml2obj-elf-bits-endian.test` is much more robust and
serves as an adequate sanity check.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183811 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-12 00:01:26 +00:00
Sean Silva
457c8ebfd0 Fix dubious type name similar to member name.
Should bring bots back to life.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183715 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-11 00:13:52 +00:00
Sean Silva
5918b7a03d [yaml2obj] Initial ELF support.
Currently, only emitting the ELF header is supported (no sections or
segments).

The ELFYAML code organization is broadly similar to the COFFYAML code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183711 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-10 23:44:15 +00:00
Kevin Enderby
285bd8e6f9 Move the test for the data in code into the ARM directory as it is an ARM
binary that is used for the test.  Caught by Jim Grosbach!

rdar://11791371


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183442 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-06 20:28:28 +00:00
Kevin Enderby
54154f3bf1 Teach llvm-objdump with the -macho parser how to use the data in code table
from the LC_DATA_IN_CODE load command.  And when disassembling print
the data in code formatted for the kind of data it and not disassemble those
bytes.

I added the format specific functionality to the derived class MachOObjectFile
since these tables only appears in Mach-O object files. This is my first
attempt to modify the libObject stuff so if folks have better suggestions
how to fit this in or suggestions on the implementation please let me know.

rdar://11791371


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183424 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-06 17:20:50 +00:00
Rafael Espindola
e3a0e7f29d Print symbol names in relocations when dumping COFF as YAML.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183403 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-06 13:06:17 +00:00
Rafael Espindola
23a22cdedd Don't print default values for NumberOfAuxSymbols and AuxiliaryData.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183293 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 03:20:13 +00:00
Rafael Espindola
6c1202c459 Handle relocations that don't point to symbols.
In ELF (as in MachO), not all relocations point to symbols. Represent this
properly by using a symbol_iterator instead of a SymbolRef. Update llvm-readobj
ELF's dumper to handle relocatios without symbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183284 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 01:33:53 +00:00
Rui Ueyama
891c0cd3c1 [Object/COFF] Fix Windows .lib name handling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183091 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-03 00:27:03 +00:00
Rafael Espindola
7486d92a6c Change how we iterate over relocations on ELF.
For COFF and MachO, sections semantically have relocations that apply to them.
That is not the case on ELF.

In relocatable objects (.o), a section with relocations in ELF has offsets to
another section where the relocations should be applied.

In dynamic objects and executables, relocations don't have an offset, they have
a virtual address. The section sh_info may or may not point to another section,
but that is not actually used for resolving the relocations.

This patch exposes that in the ObjectFile API. It has the following advantages:

* Most (all?) clients can handle this more efficiently. They will normally walk
all relocations, so doing an effort to iterate in a particular order doesn't
save time.

* llvm-readobj now prints relocations in the same way the native readelf does.

* probably most important, relocations that don't point to any section are now
visible. This is the case of relocations in the rela.dyn section. See the
updated relocation-executable.test for example.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182908 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-30 03:05:14 +00:00
Ahmed Bougacha
2c94d0faa0 Add MCSymbolizer for symbolic/annotated disassembly.
This is a basic first step towards symbolization of disassembled
instructions. This used to be done using externally provided (C API)
callbacks. This patch introduces:
- the MCSymbolizer class, that mimics the same functions that were used
  in the X86 and ARM disassemblers to symbolize immediate operands and
  to annotate loads based off PC (for things like c string literals).
- the MCExternalSymbolizer class, which implements the old C API.
- the MCRelocationInfo class, which provides a way for targets to
  translate relocations (either object::RelocationRef, or disassembler
  C API VariantKinds) to MCExprs.
- the MCObjectSymbolizer class, which does symbolization using what it
  finds in an object::ObjectFile. This makes simple symbolization (with
  no fancy relocation stuff) work for all object formats!
- x86-64 Mach-O and ELF MCRelocationInfos.
- A basic ARM Mach-O MCRelocationInfo, that provides just enough to
  support the C API VariantKinds.

Most of what works in otool (the only user of the old symbolization API
that I know of) for x86-64 symbolic disassembly (-tvV) works, namely:
- symbol references: call _foo; jmp 15 <_foo+50>
- relocations:       call _foo-_bar; call _foo-4
- __cf?string:       leaq 193(%rip), %rax ## literal pool for "hello"
Stub support is the main missing part (because libObject doesn't know,
among other things, about mach-o indirect symbols).

As for the MCSymbolizer API, instead of relying on the disassemblers
to call the tryAdding* methods, maybe this could be done automagically
using InstrInfo? For instance, even though PC-relative LEAs are used
to get the address of string literals in a typical Mach-O file, a MOV
would be used in an ELF file. And right now, the explicit symbolization
only recognizes PC-relative LEAs. InstrInfo should have already have
most of what is needed to know what to symbolize, so this can
definitely be improved.

I'd also like to remove object::RelocationRef::getValueString (it seems
only used by relocation printing in objdump), as simply printing the
created MCExpr is definitely enough (and cleaner than string concats).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182625 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-24 00:39:57 +00:00
Rafael Espindola
e67c9c341f Use std::list so that we have a stable iterator.
I will try to avoid creating these std::strings, but for now this gets
the tests passing with libc++.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182405 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 18:53:50 +00:00
Bob Wilson
ff9a6b44e0 Temporarily disable this test because it is failing when using libc++.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182212 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-19 14:59:08 +00:00
Rafael Espindola
2bbe378147 Convert obj2yaml to use yamlio.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182169 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-17 22:58:42 +00:00
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