Commit Graph

389 Commits

Author SHA1 Message Date
Rafael Espindola
2b11aef2f4 Support printing relocations in files with no section table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242998 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 09:11:05 +00:00
Rafael Espindola
a95022a4f3 Refactor duplicated code and check for invalid symbol table size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242981 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 03:24:22 +00:00
Rafael Espindola
3b12bb79e8 Force the gnu archive format to fix the test on darwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242949 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 22:09:44 +00:00
Rafael Espindola
9db135a5f1 Fix fetching the symbol table of a thin archive.
We were trying to read it as an external file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242926 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 19:34:26 +00:00
Rafael Espindola
bd58d4eb97 Identify thin archives as archives.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242921 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 18:29:39 +00:00
Michael J. Spencer
3f6881efa5 [Object][ELF] Handle files with no section header string table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242839 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 21:40:33 +00:00
Rafael Espindola
d94e17bde9 Simplify iterating over the dynamic section and report broken ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242712 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 21:23:29 +00:00
Rafael Espindola
1c12cc02fd Remove Elf_Rela_Iter and Elf_Rel_Iter.
Use just the pointers and check for invalid relocation sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242700 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 20:07:50 +00:00
Rafael Espindola
96d9043a78 Report errors an invalid virtual addresses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242676 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 14:45:03 +00:00
Rafael Espindola
9a4133e1ee Simplify iterating over program headers and detect corrupt ones.
We now use a simple pointer and have range loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242669 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 13:35:33 +00:00
Rafael Espindola
fa1a4b2275 llvm-readobj: Handle invalid references to the string table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242658 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 03:38:17 +00:00
Rafael Espindola
fc41ae8496 Move CHECKs closer to the RUN line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242657 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 03:31:25 +00:00
Rafael Espindola
d60ced8e08 llvm-readobj: call exit(1) on error.
llvm-readobj exists for testing llvm. We can safely stop the program
the first time we know the input in corrupted.

This is in preparation for making it handle a few more broken files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242656 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 03:23:55 +00:00
Rafael Espindola
2cf6eb4a42 Trying to fix the windows bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242367 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-16 00:38:34 +00:00
Rafael Espindola
6a37b479b3 Fix handling of relative paths in thin archives.
The member has to end up with a path relative to the archive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242362 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-16 00:14:49 +00:00
Rafael Espindola
167af8c16c llvm-ar: Don't write the directory in the string table.
We were already doing the right thing for short file names, but not long
ones.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242354 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-15 23:15:33 +00:00
Rafael Espindola
8d1daf644b Handle the error of trying to convert a regular archive to a thin one.
While at it, test that we can add to a thin archive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242330 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-15 20:45:56 +00:00
Rafael Espindola
4c9cd28947 Initial support for writing thin archives.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242269 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-15 05:47:46 +00:00
Rafael Espindola
0ab901ad76 Accept lower case to handle windows error messages.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242236 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 22:42:21 +00:00
Rafael Espindola
7a6e3434ba Add support for reading members out of thin archives.
For now the Archive owns the buffers of the thin archive members.
This makes for a simple API, but all the buffers are destructed
only when the archive is destructed. This should be fine since we
close the files after mmap so we should not hit an open file
limit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242215 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 22:18:43 +00:00
Rafael Espindola
6e9f427cb2 llvm-ar: Don't try to extract from thin archives.
This matches the gnu ar behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242162 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 16:55:13 +00:00
Rafael Espindola
52ed774c83 Sleep for 2.1 seconds to see if that makes the test stable on windows.
Might fix pr24106.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242158 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 16:34:23 +00:00
Rafael Espindola
4daa23f9a7 llvm-ar: print an error when the requested member is not found.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242156 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 16:02:40 +00:00
Rafael Espindola
c1abe6eb28 Rename a test. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242151 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 15:06:18 +00:00
Rafael Espindola
195dc6923a Add missing file.
Sorry about that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242083 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13 23:14:26 +00:00
Rafael Espindola
f2343bd953 Fix reading archive members with / in the name.
This is important for thin archives.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242082 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13 23:07:05 +00:00
Rafael Espindola
168b1bebf0 Add support deterministic output in llvm-ar and make it the default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242061 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13 20:38:09 +00:00
Michael J. Spencer
d37a9dfc0b [Object][ELF] Handle the dynamic string table in files without a section table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241937 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-10 20:11:57 +00:00
Michael J. Spencer
8109763d68 [Object][ELF] Support dumping hash-tables from files with no section table.
This time without breaking the bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241869 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 22:32:24 +00:00
Rafael Espindola
377796abdf Create BSD archives by default on OS X.
They should probably be created on anything that is not windows or linux, but I will
test on freebsd before changing that.

With this it is possible to bootstrap with llvm-ar instead of ar+ranlib on OS X.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241849 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 20:12:50 +00:00
Rafael Espindola
7255090cd3 llvm-ar: Pad the symbol table to 4 bytes.
It looks like ld64 requires it. With this we seem to be able to bootstrap using
llvm-ar+/usr/bin/true instead of ar+ranlib (currently on stage2).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241842 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 19:48:06 +00:00
Simon Atanasyan
ba8d948e93 [yaml2obj] Initialize sh_addralign field for the .symtab section
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241835 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 18:23:02 +00:00
Simon Atanasyan
085d10b151 [ELF] Explicitly configure sections alignment in the tests. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241834 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 18:22:55 +00:00
Rafael Espindola
c9799867af Add missing file from previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241815 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 15:58:22 +00:00
Rafael Espindola
a55816b3fc Basic support for BSD symbol tables in archives.
This could be optimized and for now we only produce __.SYMDEF
and not "__.SYMDEF SORTED".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241814 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 15:56:23 +00:00
Adrian Prantl
2efb9f7c3e Temporarily reverting 241765, 241768, and 241772 to unbreak the build bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241781 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 02:14:49 +00:00
Michael J. Spencer
7d0e4c73d4 [Object][ELF] Support dumping hash-tables from files with no section table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241765 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 00:21:06 +00:00
Rafael Espindola
a04933edc1 Don't reject an archive with just a symbol table.
It is pretty unambiguous how to interpret it and gnu ar accepts it too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241750 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08 22:27:54 +00:00
Rafael Espindola
b13e877e27 Start adding support for writing archives in BSD format.
No support for the symbol table yet (but will hopefully add it today).
We always use the long filename format so that we can align the member,
which is an advantage of the BSD format.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241721 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08 20:47:32 +00:00
Simon Atanasyan
080d7a819f [yaml2obj] Align section content using AddressAlign field's value
Use AddressAlign field's value to properly align sections content in the
yaml2obj tool. Before this change the yaml2obj ignored AddressAlign and
always aligned section on 16 bytes boundary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241674 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08 10:12:40 +00:00
Simon Atanasyan
3c1e74be73 [yaml2obj] Use regex to match sections offsets. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241669 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08 06:57:24 +00:00
Rafael Espindola
7b7c81cd35 Delete UnknownAddress. It is a perfectly valid symbol value.
getSymbolValue now returns a value that in convenient for most callers:
* 0 for undefined
* symbol size for common symbols
* offset/address for symbols the rest

Code that needs something more specific can check getSymbolFlags.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241605 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 17:12:59 +00:00
Rafael Espindola
8b3aaabd30 Common symbols are not undefined, at least for ObjectFile.
They are implemented like that in some object formats, but for the interface
provided by lib/Object, SF_Undefined and SF_Common are different things.

This matches the ELF and COFF implementation and fixes llvm-nm for MachO.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241587 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 14:26:39 +00:00
Rafael Espindola
fa2ca74300 llvm-nm: treat weak undefined as undefined.
This matches the behavior of gnu ld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241512 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-06 21:36:23 +00:00
Rafael Espindola
40b3496f9a When sorting by address, undefined symbols go first.
This matches gnu nm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241488 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-06 19:21:04 +00:00
Rafael Espindola
e473de21aa Fix printing of common symbols.
Printing the symbol size matches the behavior or both gnu nm and freebsd nm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241480 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-06 18:18:44 +00:00
Rafael Espindola
159946938f Check that COFF .obj files have sections with zero virtual address spaces.
When talking about the virtual address of sections the coff spec says:
  ... for simplicity, compilers should set this to zero. Otherwise, it is an
  arbitrary value that is subtracted from offsets during relocation.

We don't currently subtract it, so check that it is zero.

If some producer does create such files, we can change getRelocationOffset
instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241447 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-06 14:26:07 +00:00
Rafael Espindola
a25ee390b5 Fix handling of ELF::R_MIPS_32 on Mips64.
Thanks to Aboud, Amjad for reporting the regression and providing the testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241440 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-06 12:18:44 +00:00
Simon Atanasyan
afc0340d96 [ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj tools
SHT_NOBITS sections do not have content in an object file. Now the yaml2obj
tool does not accept `Content` field for such sections, and the obj2yaml
tool does not attempt to read the section content from a file.

Restore r241350 and r241352.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241377 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-03 23:00:54 +00:00
Rafael Espindola
a89ad42b36 This reverts commit r241350 and r241352.
r241350 broke lld tests.
r241352 depends on r241350.

Original messages:
"[ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj tools"
"[ELFYAML] Make the Size field for .bss section optional"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241354 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-03 14:54:02 +00:00