1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

440 Commits

Author SHA1 Message Date
Rafael Espindola
a922bf70d2 Move test since it now depends on the x86 backend.
llvm-svn: 212289
2014-07-03 20:26:21 +00:00
Rafael Espindola
1972f7d7c5 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.

llvm-svn: 212287
2014-07-03 19:40:08 +00:00
Rafael Espindola
832799f1df Add support for inline asm symbols to IRObjectFile.
This also enables it in llvm-nm so that it can be tested.

llvm-svn: 212282
2014-07-03 18:59:23 +00:00
Kevin Enderby
bfc5dbf0b6 Add the -U flag to llvm-nm as an alias to -defined-only
as darwin’s nm(1) uses -U for this functionality.

llvm-svn: 212280
2014-07-03 18:18:50 +00:00
Kevin Enderby
6e20245be0 Add the -reverse-sort flag (aka -r) to llvm-nm
which exists in other Unix nm(1)’s.

llvm-svn: 212235
2014-07-02 23:23:58 +00:00
Kevin Enderby
a6fe7b39f8 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.

llvm-svn: 212108
2014-07-01 17:19:10 +00:00
Ed Maste
b7cd23eccc 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

llvm-svn: 212059
2014-06-30 20:03:02 +00:00
Kevin Enderby
37ca7e910b 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.

llvm-svn: 212054
2014-06-30 18:45:23 +00:00
Simon Atanasyan
fb5fe85156 [ELF][Mips] Fix recognition of MIPS 64-bit arch in the ELFObjectFile:getArch() method.
llvm-svn: 211891
2014-06-27 11:36:45 +00:00
NAKAMURA Takumi
95103fb9e7 nm-trivial-object.test requires shell since Lit internal runner isn't capable of chdir.
llvm-svn: 211537
2014-06-23 21:07:04 +00:00
Kevin Enderby
95dc79eeda 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.

llvm-svn: 211529
2014-06-23 20:27:53 +00:00
Kevin Enderby
1805a9f0de 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.

llvm-svn: 211405
2014-06-20 21:29:27 +00:00
Kevin Enderby
667593db29 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.

llvm-svn: 211326
2014-06-20 00:04:16 +00:00
Kevin Enderby
f525f4ee4a 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.

llvm-svn: 211321
2014-06-19 22:49:21 +00:00
Kevin Enderby
197fe3a33d 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)".

llvm-svn: 211316
2014-06-19 22:03:18 +00:00
Kevin Enderby
b7caffa461 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.

llvm-svn: 211230
2014-06-18 22:04:40 +00:00
Kevin Enderby
ee2166f84e 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).

llvm-svn: 211117
2014-06-17 17:54:13 +00:00
Rafael Espindola
93c342bca4 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.

llvm-svn: 211036
2014-06-16 16:41:00 +00:00
Rafael Espindola
cb080681ac 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++.

llvm-svn: 210687
2014-06-11 19:05:50 +00:00
Alp Toker
03b6e12fae Reduce verbiage of lit.local.cfg files
We can just split targets_to_build in one place and make it immutable.

llvm-svn: 210496
2014-06-09 22:42:55 +00:00
Simon Atanasyan
e4655bdc7b [yaml2obj][obj2yaml] Support ELF symbol's visibility flags (default/hidden/protected).
llvm-svn: 210316
2014-06-06 07:41:57 +00:00
Kevin Enderby
f831fe0c12 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.

llvm-svn: 210285
2014-06-05 21:21:57 +00:00
Simon Atanasyan
96f205e49a [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.

llvm-svn: 209967
2014-05-31 04:51:07 +00:00
Simon Atanasyan
9e2e4f182a [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.

llvm-svn: 209801
2014-05-29 11:05:31 +00:00
NAKAMURA Takumi
b27e1f0470 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.

llvm-svn: 209570
2014-05-24 08:47:11 +00:00
Simon Atanasyan
f56e5acb21 [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.

llvm-svn: 209504
2014-05-23 08:07:09 +00:00
Filipe Cabecinhas
15bb1703a1 llvm-ar: Output the file we errored on.
llvm-svn: 209500
2014-05-23 05:52:12 +00:00
Kevin Enderby
9ee20001f3 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.

llvm-svn: 209253
2014-05-20 23:04:47 +00:00
Kevin Enderby
35b1659e80 Revert r209235 as it broke two tests:
Failing Tests (2):
	    LLVM :: ExecutionEngine/MCJIT/stubs-sm-pic.ll
	    LLVM :: ExecutionEngine/MCJIT/stubs.ll

llvm-svn: 209236
2014-05-20 21:10:15 +00:00
Kevin Enderby
96dd7fc245 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.

llvm-svn: 209235
2014-05-20 20:32:18 +00:00
Kevin Enderby
329b5c1fea 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.

llvm-svn: 209158
2014-05-19 20:36:02 +00:00
Simon Atanasyan
808d7bc7a0 [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.

llvm-svn: 208995
2014-05-16 16:01:00 +00:00
Simon Atanasyan
e9f0f263e7 [obj2yaml][ELF] Print relocation's offset as a hex number. Use a proper
types to hold relocation's offset and addend.

llvm-svn: 208906
2014-05-15 18:04:09 +00:00
Simon Atanasyan
c65a88ecce [obj2yaml][ELF] Do not print empty Link and Info fields for ELF sections.
llvm-svn: 208905
2014-05-15 18:04:02 +00:00
Simon Atanasyan
dc1b209153 [yaml2obj] Add "-o" command line option to specify an output file name.
llvm-svn: 208900
2014-05-15 16:14:02 +00:00
Kevin Enderby
7558c9cb9b Teach llvm-nm to know about fat archives (aka MachOUniversal files
containing archives).  First step as other tools will be updated next.

llvm-svn: 208812
2014-05-14 21:18:50 +00:00
Simon Atanasyan
9b2d085924 [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.

llvm-svn: 208752
2014-05-14 05:07:47 +00:00
Kevin Enderby
e6f49d1bca 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.

llvm-svn: 208463
2014-05-09 23:57:49 +00:00
Simon Atanasyan
9082e5461c [yaml2obj] Follow-up to the r208228 and r208406. Remove duplicated YAML
map keys.

llvm-svn: 208412
2014-05-09 13:57:33 +00:00
NAKAMURA Takumi
e7098b6cd1 Mark yaml2obj-elf-x86-rel.yaml as XFAIL:vg_leak for now. This has two pairs of duplicate hashes.
llvm-svn: 208406
2014-05-09 11:24:18 +00:00
Simon Atanasyan
a8319970e6 [yaml2obj] Support ELF x86 relocations.
llvm-svn: 208228
2014-05-07 17:06:38 +00:00
Simon Atanasyan
a758825238 [llvm-readobj] Add support for Mips specific ELF header e_flags.
llvm-svn: 207744
2014-05-01 11:07:19 +00:00
Hans Wennborg
1c82481522 Use the new StringTableBuilder in yaml2elf
http://reviews.llvm.org/D3574

llvm-svn: 207694
2014-04-30 19:38:09 +00:00
Chandler Carruth
11e2973f4a 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...

llvm-svn: 207387
2014-04-28 01:24:32 +00:00
Simon Atanasyan
129c45d10c [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.

llvm-svn: 206017
2014-04-11 04:13:39 +00:00
David Majnemer
60de53a3e4 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.

llvm-svn: 205955
2014-04-10 07:37:33 +00:00
David Majnemer
38564aab17 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.

llvm-svn: 205914
2014-04-09 17:04:27 +00:00
David Majnemer
22c9e46ce7 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.

llvm-svn: 205911
2014-04-09 16:38:15 +00:00
Filipe Cabecinhas
ee5a23fda4 Revert "YAMLIO: Encode ambiguous hex strings explicitly"
This reverts commit r205839.

It broke several tests in lld.

llvm-svn: 205857
2014-04-09 14:35:17 +00:00
David Majnemer
c51365b164 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.

llvm-svn: 205839
2014-04-09 07:56:27 +00:00
David Majnemer
247d9155db 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.

llvm-svn: 205746
2014-04-07 23:12:20 +00:00
Rafael Espindola
c4dd200975 Implement getRelocationAddress for MachO and ET_REL elf files.
With that, fix the symbolizer to work with any ELF file.

llvm-svn: 205588
2014-04-03 23:54:35 +00:00
Rafael Espindola
7752d2f349 Only clear the thumb bit from function addresses.
llvm-svn: 205500
2014-04-03 02:20:43 +00:00
Rafael Espindola
1cc921e760 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.

llvm-svn: 205493
2014-04-03 00:19:35 +00:00
Daniel Sanders
9a1bf52b88 [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

llvm-svn: 205173
2014-03-31 09:44:05 +00:00
Rafael Espindola
592a9a42e8 Teach llvm-readobj to print human friendly description of reserved sections.
llvm-svn: 204584
2014-03-24 05:00:34 +00:00
David Majnemer
f8e66b9d3f Object: Output .file symbols properly
obj2yaml would emit the NUL bytes padding the auxiliary file symbol
records.  Trimming them looks nicer.

llvm-svn: 204314
2014-03-20 06:29:02 +00:00
David Majnemer
4534e0a71a 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

llvm-svn: 204214
2014-03-19 04:47:47 +00:00
Simon Atanasyan
ec2f02d37d [yaml2obj][ELF] Assign name (.shstrtab) to the section holds sections names.
llvm-svn: 203897
2014-03-14 06:53:16 +00:00
Rafael Espindola
e3d6551059 Now that it is possible, use the mangler in IRObjectFile.
A really simple patch marks the end of a lot of yak shaving :-)

llvm-svn: 202463
2014-02-28 02:17:23 +00:00
Rafael Espindola
43f88a22f0 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.

llvm-svn: 201881
2014-02-21 20:10:59 +00:00
Rafael Espindola
9f34f7c6db Add a test for printing absolute symbols in ELF.
llvm-svn: 200818
2014-02-05 04:36:47 +00:00
Rafael Espindola
e2cb6619df Small fix for llvm-nm handling of weak symbols on ELF (print 'v').
llvm-svn: 200808
2014-02-04 23:53:15 +00:00
Rafael Espindola
14250cad7d Add a test for common symbols in coff.
llvm-svn: 200803
2014-02-04 23:18:52 +00:00
Rafael Espindola
5cde3516d0 Mark the first dynamic elf symbol as SF_FormatSpecific.
llvm-svn: 200578
2014-01-31 21:40:13 +00:00
Rafael Espindola
fae4ff3453 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.

llvm-svn: 200488
2014-01-30 20:45:33 +00:00
Rafael Espindola
02756a4dec This has been fixed.
llvm-svn: 200487
2014-01-30 20:29:25 +00:00
Rafael Espindola
79d6988d0d Fix TLS handling in ELF's getAddress and llvm-nm to print 'D' for it.
llvm-svn: 200433
2014-01-30 00:42:30 +00:00
Rafael Espindola
2eee1a2756 We do use pipefail these days. Update the test.
llvm-svn: 200370
2014-01-29 04:08:05 +00:00
Mark Seaborn
4146b9618e 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

llvm-svn: 200090
2014-01-25 17:38:19 +00:00
Simon Atanasyan
f2ddc8cbe5 [Object][ELF][Mips] Print symbol name for MIPS ELF relocations.
llvm-svn: 199898
2014-01-23 15:05:45 +00:00
Bill Wendling
f6124a0f65 Fix typo: : not ;
llvm-svn: 199359
2014-01-16 07:08:22 +00:00
Rafael Espindola
17fc3635ef Make sure we create a new archive by deleting any stale ones first.
llvm-svn: 199319
2014-01-15 16:56:57 +00:00
Alp Toker
e845f8af67 Correct word hyphenations
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities and contractions in nearby lines.

llvm-svn: 196471
2013-12-05 05:44:44 +00:00
NAKAMURA Takumi
ad0df78440 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.
llvm-svn: 194257
2013-11-08 12:35:56 +00:00
Rafael Espindola
1506f61a81 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.

llvm-svn: 193912
2013-11-02 05:03:24 +00:00
Rafael Espindola
090358f57a Create an atom with just the data that failed to disassemble.
Patch by Stephen Checkoway.

llvm-svn: 192827
2013-10-16 19:03:14 +00:00
Simon Atanasyan
724835dff7 [Mips] Teach llvm-readobj to print MIPS-specific ELF program headers.
The patch reviewed by Michael Spencer.
http://llvm-reviews.chandlerc.com/D1846

llvm-svn: 192093
2013-10-07 08:58:27 +00:00
Rafael Espindola
695620f5e9 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.

llvm-svn: 189489
2013-08-28 16:22:16 +00:00
Ahmed Bougacha
3e1fe16ca3 MC CFG: Remap enough for data too, analoguous to r188873.
llvm-svn: 188925
2013-08-21 19:40:28 +00:00
Ahmed Bougacha
49ff5d404a Add testcase for r188873: MCTextAtom boundaries.
Check that they are correctly computed if the last instruction is
larger than 1 byte.

llvm-svn: 188923
2013-08-21 19:40:22 +00:00
Ahmed Bougacha
f1b8b6c212 Add basic YAML MC CFG testcase.
Drive-by llvm-objdump cleanup (don't hardcode ToolName).

llvm-svn: 188904
2013-08-21 16:13:25 +00:00
Ahmed Bougacha
60a189fbc9 MC: ObjectSymbolizer can now recognize external function stubs.
Only implemented in the Mach-O ObjectSymbolizer.
The testcase sadly introduces a new binary.

llvm-svn: 188879
2013-08-21 07:28:13 +00:00
Daniel Dunbar
a496d61c01 [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.

llvm-svn: 188513
2013-08-16 00:37:11 +00:00
Michael J. Spencer
8cdf1cca41 [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.

llvm-svn: 188022
2013-08-08 22:27:13 +00:00
Rafael Espindola
ca0a1505ba 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.

llvm-svn: 187353
2013-07-29 12:40:31 +00:00
Rafael Espindola
081f6f185f 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.

llvm-svn: 186934
2013-07-23 10:47:01 +00:00
Rafael Espindola
b5df8607a3 Mark ELF's first symbol as format specific so that llvm-nm ignores it.
llvm-svn: 186860
2013-07-22 19:24:34 +00:00
Rafael Espindola
9cfbdad631 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.

llvm-svn: 186829
2013-07-22 15:11:51 +00:00
Rafael Espindola
ce62c0a883 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.

llvm-svn: 186823
2013-07-22 12:41:04 +00:00
Rafael Espindola
c2acfa8f64 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.

llvm-svn: 186792
2013-07-21 12:58:07 +00:00
Rafael Espindola
e054c779bd Fix inserting new elements in a specified location.
We were only handling the 'a' and 'b' options during moves before.

llvm-svn: 186721
2013-07-19 21:23:28 +00:00
Rafael Espindola
f40c5de45c Split openFileForWrite into windows and unix versions.
It is similar to 186511, but for creating files for writing.

llvm-svn: 186679
2013-07-19 15:02:03 +00:00
Rafael Espindola
a045716bb8 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.

llvm-svn: 186511
2013-07-17 14:58:25 +00:00
NAKAMURA Takumi
26b99c6974 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.

llvm-svn: 186480
2013-07-17 02:21:10 +00:00
NAKAMURA Takumi
67f8f68d48 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.

llvm-svn: 186469
2013-07-16 23:17:22 +00:00
NAKAMURA Takumi
3c613c0b6c llvm/test/Object/check_binary_output.ll: Mark it as XFAIL on Windows. Investigating.
llvm-svn: 186468
2013-07-16 23:16:57 +00:00
Rafael Espindola
77c12b390e On error, close the temporary file descriptor.
With this change llvm-ar can remove the temporary file on windows too.

llvm-svn: 186423
2013-07-16 16:00:32 +00:00
NAKAMURA Takumi
095a932723 llvm/test/Object/directory.ll: Mark it as XFAIL:cygwin. Directories can be opened on cygwin.
llvm-svn: 186387
2013-07-16 09:06:47 +00:00
NAKAMURA Takumi
3402033e2b 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?
llvm-svn: 186374
2013-07-16 02:43:51 +00:00
Rafael Espindola
e07303b68d Add mingw32 to the XFAIL. I forgot about it when adding win32.
llvm-svn: 186365
2013-07-15 23:51:47 +00:00
Rafael Espindola
1a2bc927ed XFAIL on windows too and document the XFAILs.
llvm-svn: 186354
2013-07-15 22:16:53 +00:00
Rafael Espindola
34f661d762 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.

llvm-svn: 186317
2013-07-15 12:18:30 +00:00
NAKAMURA Takumi
1aa6823278 Mark llvm/test/Object/extract.ll as XFAIL:mingw32, for now.
FIXME: Investigate Win32's TimeValue stuff!
llvm-svn: 186298
2013-07-15 03:04:13 +00:00
Chandler Carruth
c53cd157aa 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.

llvm-svn: 186282
2013-07-14 10:46:51 +00:00
Benjamin Kramer
740741f2c0 Only verify the length in archive test, we can't make assumptions on the spacing.
And .* did just match about anything anyways.

llvm-svn: 186246
2013-07-13 15:21:39 +00:00
Rafael Espindola
9e9a37033b 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.

llvm-svn: 186238
2013-07-13 04:14:13 +00:00
Chandler Carruth
40918c60f8 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.

llvm-svn: 186232
2013-07-13 00:42:56 +00:00
Rafael Espindola
d955e6ac00 Fix a off by one error about which members need to use the string table.
llvm-svn: 186216
2013-07-12 22:22:34 +00:00
Rafael Espindola
49171a7db7 Change archive-update.test to create a new file on the fly.
llvm-svn: 186206
2013-07-12 21:17:17 +00:00
Rafael Espindola
6cc9c76d58 Rename directory to avoid problems on windows.
llvm-svn: 186202
2013-07-12 20:53:23 +00:00
Rafael Espindola
6c3ac6c001 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.

llvm-svn: 186197
2013-07-12 20:21:39 +00:00
Rafael Espindola
b62b63af64 Add a test for llvm-ar's u option.
llvm-svn: 186192
2013-07-12 19:34:24 +00:00
Rafael Espindola
96f432c795 Relax the test a bit more to handle different UIDs and GIDs.
llvm-svn: 186186
2013-07-12 19:13:16 +00:00
Rafael Espindola
67d6fae59a Relax test a bit to handle umask differences.
llvm-svn: 186184
2013-07-12 18:54:28 +00:00
Rafael Espindola
55b2c00b7d Add a test for the 'o' option in llvm-ar.
llvm-svn: 186183
2013-07-12 18:51:25 +00:00
Rafael Espindola
f735609444 Don't reject an empty archive.
llvm-svn: 186159
2013-07-12 13:32:28 +00:00
NAKAMURA Takumi
8e9b7d6d74 llvm/test/Object/archive-toc.test: Use env(1) to satisfy win32 hosts.
llvm-svn: 186143
2013-07-12 02:34:45 +00:00
Rafael Espindola
afa501d655 Add tests for the before and after modifiers.
llvm-svn: 186118
2013-07-11 21:11:55 +00:00
Rafael Espindola
f9a1792687 Add a test for llvm-ar's m operation.
llvm-svn: 186110
2013-07-11 19:09:04 +00:00
Rafael Espindola
f1b5484cf9 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.

llvm-svn: 186090
2013-07-11 15:35:23 +00:00
Rafael Espindola
f9f9d1648c Merge these tests.
llvm-svn: 186084
2013-07-11 13:44:10 +00:00
Rafael Espindola
948310c9c0 Use a more unique name to avoid conflicting with directory.ll tests when running
in parallel.

llvm-svn: 186083
2013-07-11 13:31:38 +00:00
Rafael Espindola
d7f85dd49b Add a test for llvm-ar's 'd' operation.
llvm-svn: 186082
2013-07-11 13:24:27 +00:00
Rafael Espindola
3395d4e371 Add tests for the 'x' operation.
llvm-svn: 186081
2013-07-11 13:13:09 +00:00
Rafael Espindola
a639b1d8e8 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).

llvm-svn: 186043
2013-07-10 22:15:29 +00:00
Rafael Espindola
a18221a110 Find the symbol table on archives created on OS X.
llvm-svn: 186041
2013-07-10 22:07:59 +00:00
Rafael Espindola
1974e1f8d7 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.

llvm-svn: 186038
2013-07-10 21:47:16 +00:00
Rafael Espindola
912eeb2ecb Don't crash in 'llvm -s' when an archive has no symtab.
llvm-svn: 186029
2013-07-10 20:14:22 +00:00
Rafael Espindola
92517e5f29 Don't create an archive if, for example, we are asked to print the index.
llvm-svn: 185697
2013-07-05 13:03:07 +00:00
Rafael Espindola
cf97ffa6e3 Add support for archives with no symbol table or string table.
llvm-svn: 185664
2013-07-04 19:40:23 +00:00
Rafael Espindola
4f28e3be09 Add support for gnu archives with a string table and no symtab.
While there, use early returns to reduce nesting.

llvm-svn: 185547
2013-07-03 15:57:14 +00:00
Rafael Espindola
69d633e340 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.

llvm-svn: 185546
2013-07-03 15:46:03 +00:00
Sean Silva
726b33f897 [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.

llvm-svn: 184627
2013-06-22 01:38:00 +00:00
Sean Silva
5a502b4c07 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.

llvm-svn: 184607
2013-06-21 23:17:13 +00:00
Sean Silva
e0d951406d 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.

llvm-svn: 184606
2013-06-21 23:17:10 +00:00
Renato Golin
50a971563f Put r184469 disassembler test back on X86
llvm-svn: 184602
2013-06-21 22:42:20 +00:00
Sean Silva
e1eda4088d [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?

llvm-svn: 184597
2013-06-21 21:51:15 +00:00
Sean Silva
13fa254a61 [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.

llvm-svn: 184513
2013-06-21 01:11:48 +00:00
Sean Silva
891dc92008 [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 ;)

llvm-svn: 184506
2013-06-21 00:27:50 +00:00
Sean Silva
873dafebc7 [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!

llvm-svn: 184469
2013-06-20 20:59:47 +00:00
Sean Silva
b8315826cf [yaml2obj][ELF] Allow symbols to reference sections.
llvm-svn: 184468
2013-06-20 20:59:41 +00:00
Rafael Espindola
902c5e858b 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.

llvm-svn: 184424
2013-06-20 13:44:49 +00:00
Sean Silva
0c458f147b [yaml2obj][ELF] Beef up this test a bit.
llvm-svn: 184269
2013-06-19 00:55:32 +00:00
Sean Silva
a39ac0fdeb [yaml2obj][ELF] Support ELFOSABI_* enum.
llvm-svn: 184268
2013-06-19 00:55:28 +00:00
Sean Silva
c7a5f8cb18 [yaml2obj][ELF] Support st_info through Binding and Type YAML keys.
llvm-svn: 184263
2013-06-19 00:11:59 +00:00
Sean Silva
3fd655ca4d [yaml2obj][ELF] Ensure STN_UNDEF entry is present.
llvm-svn: 184258
2013-06-18 23:19:17 +00:00
Sean Silva
beed0c8948 [yaml2obj][ELF] Rudimentary symbol table support.
Currently, we only output the name.

llvm-svn: 184255
2013-06-18 23:14:03 +00:00
Alexey Samsonov
50c414e3d0 Basic support for parsing Mach-O universal binaries in LLVMObject library
llvm-svn: 184191
2013-06-18 15:03:28 +00:00
Sean Silva
7dafd05c2e [yaml2obj] Add support for sh_link via Link key.
llvm-svn: 184022
2013-06-15 00:25:26 +00:00
Sean Silva
221b8835d3 [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.

llvm-svn: 183962
2013-06-14 00:38:02 +00:00
Sean Silva
51f6318c1e [yaml2obj] Add support for specifying raw section content.
llvm-svn: 183955
2013-06-13 22:20:01 +00:00
Sean Silva
a31cf66d83 [yaml2obj] Add sh_addr via Address key.
llvm-svn: 183954
2013-06-13 22:19:54 +00:00
Sean Silva
c72d9620ea [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.

llvm-svn: 183953
2013-06-13 22:19:48 +00:00
Sean Silva
7e14cf65e1 [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.

llvm-svn: 183811
2013-06-12 00:01:26 +00:00
Sean Silva
0145eeb66d Fix dubious type name similar to member name.
Should bring bots back to life.

llvm-svn: 183715
2013-06-11 00:13:52 +00:00
Sean Silva
141d676063 [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.

llvm-svn: 183711
2013-06-10 23:44:15 +00:00
Kevin Enderby
9032830bea 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

llvm-svn: 183442
2013-06-06 20:28:28 +00:00
Kevin Enderby
644e3fc29e 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

llvm-svn: 183424
2013-06-06 17:20:50 +00:00
Rafael Espindola
a1d5ce4045 Print symbol names in relocations when dumping COFF as YAML.
llvm-svn: 183403
2013-06-06 13:06:17 +00:00
Rafael Espindola
eea6425b38 Don't print default values for NumberOfAuxSymbols and AuxiliaryData.
llvm-svn: 183293
2013-06-05 03:20:13 +00:00
Rafael Espindola
6f41305fd8 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.

llvm-svn: 183284
2013-06-05 01:33:53 +00:00
Rui Ueyama
ab6877d693 [Object/COFF] Fix Windows .lib name handling.
llvm-svn: 183091
2013-06-03 00:27:03 +00:00
Rafael Espindola
5b34d5a3c7 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.

llvm-svn: 182908
2013-05-30 03:05:14 +00:00
Ahmed Bougacha
6979d48fa4 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).

llvm-svn: 182625
2013-05-24 00:39:57 +00:00
Rafael Espindola
f356145124 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++.

llvm-svn: 182405
2013-05-21 18:53:50 +00:00
Bob Wilson
d5833c69b3 Temporarily disable this test because it is failing when using libc++.
llvm-svn: 182212
2013-05-19 14:59:08 +00:00
Rafael Espindola
c0de1ee01b Convert obj2yaml to use yamlio.
llvm-svn: 182169
2013-05-17 22:58:42 +00:00
Ahmed Bougacha
4bf012e2e6 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.

llvm-svn: 181843
2013-05-14 22:41:29 +00:00
Rafael Espindola
56fa3ce519 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.

llvm-svn: 181502
2013-05-09 03:39:05 +00:00
Rafael Espindola
d896db3c7d 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.

llvm-svn: 181243
2013-05-06 20:11:21 +00:00
Amara Emerson
036eb4649d Revert r181009.
llvm-svn: 181079
2013-05-03 23:57:17 +00:00
Amara Emerson
a0c67cd288 Delete test instead.
llvm-svn: 181066
2013-05-03 22:39:03 +00:00
Amara Emerson
63cfb8d51f Temporarily disable failing test.
llvm-svn: 181062
2013-05-03 22:27:48 +00:00
Amara Emerson
863672f436 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.

llvm-svn: 181009
2013-05-03 11:36:35 +00:00
Rafael Espindola
008c3f4ae4 Add missing ':'.
llvm-svn: 180616
2013-04-26 17:54:46 +00:00
Rafael Espindola
9541db893e 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.

llvm-svn: 180259
2013-04-25 12:28:45 +00:00
Rafael Espindola
3d1e86bc2f Fix typo.
llvm-svn: 180137
2013-04-23 19:39:34 +00:00
Rafael Espindola
534f0bf6c6 Write relocations in yaml2obj.
llvm-svn: 180115
2013-04-23 15:53:02 +00:00
Eric Christopher
95e5e9b173 Add .ll as a valid test suffix for Object, this allows .ll -> object
and then dumping as tests.

llvm-svn: 180010
2013-04-22 10:45:06 +00:00
Rafael Espindola
96eb421cc7 Only run the tests in test/Object/ARM if we have ARM support.
llvm-svn: 179850
2013-04-19 12:47:53 +00:00
Rafael Espindola
f56c9bfd51 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.

llvm-svn: 179848
2013-04-19 11:36:47 +00:00
Alexey Samsonov
8fcb809efb llvm-objdump: Don't print contents of BSS sections: it makes no sense and crashes llvm-objdump on relocated objects with large bss
llvm-svn: 179589
2013-04-16 10:53:11 +00:00
Rafael Espindola
98c3e8bc71 Add a test for obj2yaml in preparation for refactoring it.
llvm-svn: 178829
2013-04-05 02:02:05 +00:00
Rafael Espindola
5e796656b1 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.

llvm-svn: 178786
2013-04-04 20:30:52 +00:00
Rafael Espindola
af01832c73 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.

llvm-svn: 178694
2013-04-03 21:02:51 +00:00
Eric Christopher
df46cef31b 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!

llvm-svn: 178679
2013-04-03 18:31:38 +00:00
Eric Christopher
99a330354d Implement sectionContainsSymbol for ELF.
Patch by Nico Rieck!

llvm-svn: 178677
2013-04-03 18:31:19 +00:00
Eric Christopher
8cfce53956 When dumping clear the arm/thumb flag for now.
Patch by Nico Rieck!

llvm-svn: 178676
2013-04-03 18:31:12 +00:00
Shankar Easwaran
74225248db [tools][llvm-readobj] print the name of the section when iterating the symbol table / dynamic symbol table
llvm-svn: 177873
2013-03-25 16:06:51 +00:00
Michael J. Spencer
6270bca74a [llvm-readobj] Add ELF .dynamic table dumping.
llvm-svn: 175592
2013-02-20 02:37:12 +00:00
Michael J. Spencer
d9e9c95c02 [Object][ELF] Fix crash on no dynamic section.
llvm-svn: 174639
2013-02-07 18:26:45 +00:00
Michael J. Spencer
6a1aee19b4 [llvm-objdump] Emit addresses with the correct number of leading 0's.
llvm-svn: 172130
2013-01-10 22:40:50 +00:00
Michael J. Spencer
44db267406 [Object][ELF] Fix incorrect size of members for the 64 version of Elf_Phdr_Impl.
llvm-svn: 171650
2013-01-06 03:57:11 +00:00
Michael J. Spencer
b8ff7ef369 [objdump] Add --private-headers, -p.
This currently prints the ELF program headers.

llvm-svn: 171649
2013-01-06 03:56:49 +00:00
Michael J. Spencer
641cf62d29 [Object][ELF] Add a maximum alignment. This is used by createELFObjectFile to create a properly aligned reader.
llvm-svn: 171520
2013-01-04 20:36:28 +00:00
Michael J. Spencer
8246b2fd6b [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.

llvm-svn: 171438
2013-01-03 01:24:32 +00:00
Rafael Espindola
3e79a98c7f Fix bits check in ELFObjectFile::isSectionZeroInit().
Fixes PR14723.

Patch by Sami Liedes!

llvm-svn: 171309
2012-12-31 18:20:51 +00:00
Rafael Espindola
4224ad9911 Dump sections. Extracted from a patch by Sami Liedes.
llvm-svn: 171304
2012-12-31 16:29:44 +00:00
Rafael Espindola
812bc66ae6 Print a header above the symbols. Extracted from a patch by Sami Liedes.
llvm-svn: 171302
2012-12-31 16:05:21 +00:00
Tim Northover
5f7dc099cf Teach MachO which sections contain code
llvm-svn: 170349
2012-12-17 17:59:32 +00:00
Shankar Easwaran
eb6f136f28 numerically sort the symbols, so that the testcase result is uniform
llvm-svn: 167872
2012-11-13 21:01:11 +00:00
Daniel Dunbar
6579221af6 llvm-nm: Make sort more stable when symbol names are equal.
llvm-svn: 167866
2012-11-13 19:39:55 +00:00
Shankar Easwaran
f934185b04 Adding changes to support GNU style archive library reading
llvm-svn: 167853
2012-11-13 18:38:42 +00:00
Alexey Samsonov
ad52a8844e 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.
llvm-svn: 164365
2012-09-21 07:08:08 +00:00
Nick Lewycky
6e3f6cb8d7 Add missing file for test.
llvm-svn: 163272
2012-09-05 23:52:20 +00:00
Nick Lewycky
6e821e0321 Teach libObject about some more ELF relocations. llvm-objdump -r now knows
every relocation in C++ hello world built with debug info.

llvm-svn: 163271
2012-09-05 23:48:54 +00:00
NAKAMURA Takumi
46ead41fe9 Create llvm/test/Object/Mips/lit.local.cfg to check Mips in targets_to_build.
llvm-svn: 162819
2012-08-29 01:37:57 +00:00
Jack Carter
e48124ec30 Moved input for objdump test from Mips to Inputs.
llvm-svn: 162808
2012-08-29 00:10:48 +00:00
Jack Carter
c0c7230823 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.

llvm-svn: 162781
2012-08-28 19:24:49 +00:00
Matt Beaumont-Gay
c2514fd0f4 Move test yaml files under Inputs until they are converted to be the actual
test files.

llvm-svn: 161219
2012-08-02 21:52:49 +00:00
Michael J. Spencer
9f255feb3f 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.

llvm-svn: 161205
2012-08-02 19:16:56 +00:00
Marshall Clow
b34fa3efd3 Add relocation types for Hexagon processor; patch by Sidney Manning <sidneym@codeaurora.org>
llvm-svn: 159081
2012-06-23 14:46:18 +00:00
Eli Bendersky
3ef88c1833 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

llvm-svn: 153408
2012-03-25 09:02:19 +00:00
David Meyer
d29d7cfe60 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

llvm-svn: 152436
2012-03-09 20:59:52 +00:00
David Meyer
7f21ecb667 [Object]
Add ObjectFile::getLoadName() for retrieving the soname/installname of a shared object.

llvm-svn: 151845
2012-03-01 22:19:54 +00:00
David Meyer
44201a2d17 [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.

llvm-svn: 151785
2012-03-01 01:36:50 +00:00
Michael J. Spencer
0aef1b9f18 [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.

llvm-svn: 151600
2012-02-28 00:40:37 +00:00
Eli Bendersky
4afdeeb682 Replace all instances of dg.exp file with lit.local.cfg, since all tests are run with LIT now and now Dejagnu. dg.exp is no longer needed.
Patch reviewed by Daniel Dunbar. It will be followed by additional cleanup patches.

llvm-svn: 150664
2012-02-16 06:28:33 +00:00
Danil Malyshev
5ce4e1a9d3 Fixed ObjectFile functions:
- getSymbolOffset() renamed as getSymbolFileOffset()
- getSymbolFileOffset(), getSymbolAddress(), getRelocationAddress() returns same result for ELFObjectFile, MachOObjectFile and COFFObjectFile.
- added getRelocationOffset()
- fixed MachOObjectFile::getSymbolSize()
- fixed MachOObjectFile::getSymbolSection()
- fixed MachOObjectFile::getSymbolOffset() for symbols without section data.

llvm-svn: 145408
2011-11-29 17:40:10 +00:00
Eli Friedman
172ff3d328 Move x86-specific tests into X86 folder.
llvm-svn: 143424
2011-11-01 03:21:48 +00:00
Matt Beaumont-Gay
6f16a87ae3 Change the actual tests to match the input directory rename (duh)
llvm-svn: 143404
2011-10-31 23:56:52 +00:00
Matt Beaumont-Gay
a5dfba561b Rename "TestObjectFiles" to "Inputs" (like the pattern for Clang tests)
llvm-svn: 143400
2011-10-31 23:46:38 +00:00
Michael J. Spencer
c59705a3bc Object: change test to create archive.
llvm-svn: 142982
2011-10-25 22:30:58 +00:00
Michael J. Spencer
f21a701890 llvm-objdump: Add static symbol table dumping.
llvm-svn: 142404
2011-10-18 19:32:17 +00:00
Michael J. Spencer
00c39291ef Revert "llvm-objdump: Add static symbol table dumping."
This reverts commit 0c30d4e4f5f9110c5a67bd0ca84444dc58697596.

llvm-svn: 142320
2011-10-18 00:17:04 +00:00
Michael J. Spencer
8c590fd08d llvm-objdump: Add static symbol table dumping.
llvm-svn: 142319
2011-10-17 23:55:22 +00:00
Michael J. Spencer
277eaf9f19 llvm-objdump: Add -s, which prints the contents of each section.
llvm-svn: 142199
2011-10-17 17:13:22 +00:00
Michael J. Spencer
689903addb llvm-objdump: Add tests.
llvm-svn: 142198
2011-10-17 17:13:05 +00:00
Michael J. Spencer
10caa055b0 ELF: Fix the section that relocations apply to. Add test to verify. Patch by Danil Malyshev!
llvm-svn: 141901
2011-10-13 22:30:10 +00:00
Michael J. Spencer
4ee36e15ad llvm-object: Add inline relocation information to disassembly.
llvm-svn: 141897
2011-10-13 22:17:18 +00:00
Nick Lewycky
73e4d372d0 Add support for dumping section headers to llvm-objdump. This uses the same
flags as binutils objdump but the output is different, not just in format but
also showing different sections. Compare its results against readelf, not
objdump.

llvm-svn: 141579
2011-10-10 21:21:34 +00:00
Michael J. Spencer
e497728e76 llvm-objdump: Add relocation and archive support.
llvm-svn: 141451
2011-10-08 00:18:30 +00:00
Michael J. Spencer
89e83b38cd Add binary archive support to llvm-nm.
llvm-svn: 140627
2011-09-27 19:37:18 +00:00
Michael J. Spencer
6510b463d3 Unbreak tests.
llvm-svn: 140622
2011-09-27 19:06:37 +00:00
Michael J. Spencer
08bf1dbce4 Revert "Object: Renable the tests now that none of the build bots complain about aliasing."
This reverts commit 281f3901b7b0869929caf8946c1ad1228bc38922.

llvm-svn: 123972
2011-01-21 06:27:04 +00:00
Michael J. Spencer
3089c44b26 Object: Renable the tests now that none of the build bots complain about aliasing.
llvm-svn: 123964
2011-01-21 05:07:13 +00:00
Devang Patel
e3e6201a2f Disable objdump-trivial-object.test. It is broken on powerpc-darwin9.
llvm-svn: 123928
2011-01-20 18:08:44 +00:00
Michael J. Spencer
d74f931baa Disable this test until I can figure out why it's broken. Not xfailed because it
usese 100% CPU and times out, so it's annoying to run it.

llvm-svn: 123915
2011-01-20 16:24:07 +00:00
Michael J. Spencer
c3f075e648 Object: Add some tests!
llvm-svn: 123899
2011-01-20 06:39:15 +00:00