Commit Graph

56 Commits

Author SHA1 Message Date
NAKAMURA Takumi
e225c19562 llvm/tools: Prune redundant target_link_libraries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200559 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31 17:40:06 +00:00
NAKAMURA Takumi
3aabdebde2 [CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196908 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 11:13:32 +00:00
Will Dietz
6dd7893e8c yaml2coff/elf: Touchup for compatibility.
* std::string::append(int, int) can be ambiguous.
* std::vector<>::data() is a C++11 feature, use ArrayRef abstraction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192542 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-12 21:29:16 +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
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
681dafbb6c [yaml2obj][ELF] Narrow parameter.
The full ELFYAML::Section isn't needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184626 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-22 01:37:55 +00:00
Sean Silva
58495694c0 [yaml2obj][ELF] Don't special case writing these.
Just add them to the vector of section headers like the rest of the
section headers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184624 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-22 01:06:12 +00:00
Sean Silva
efc78986b3 [yaml2obj][ELF] Make this "type switch" actually readable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184623 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-22 01:03:35 +00:00
Sean Silva
e766884193 [yaml2obj][ELF] Align section contents in the output.
The improperly aligned section content in the output was causing
buildbot failures. This should fix them.

Incidentally, this results in a simpler and more robust API for
ContiguousBlobAccumulator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184621 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-22 00:47:43 +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
552d7cd31a Unbreak bots. Didn't realize this was a C++11 feature.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184508 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21 00:33:01 +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
Sean Silva
c18f66e70d [yaml2obj][ELF] Add the section name -> section index map to State.
One of the key things that the YAML format abstracts over is the use of
section numbers for referencing sections. Instead, textual section names
are used, which yaml2obj then translates into appropriate section
numbers. (Technically ELF doesn't care about section names (only section
numbers), but since this is a testing tool, readability counts).

This simplifies using section names as symbolic references in various
parts of the code. An upcoming commit will use this to allow symbols to
reference sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184467 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-20 20:59:34 +00:00
Sean Silva
0382b30eb5 [yaml2obj][ELF] Start factoring into "single point of truth".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184457 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-20 19:11:44 +00:00
Sean Silva
b14f972ed6 [yaml2obj][ELF] Just let this class own its buffer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184456 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-20 19:11:41 +00:00
Sean Silva
e1e1bb1b36 Remove using namespace and use explicit qualification.
There were only two places it was actually making anything shorter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184273 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-19 01:13:28 +00:00
Sean Silva
83bc34561b Remove spurious space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184272 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-19 01:10:58 +00:00
Sean Silva
9e82a5c767 Remove unused parameter.
Not sure why we weren't catching this with -Wunused-parameter...

Spotted by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184271 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-19 01:10:11 +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
1230407e34 There is no ELF ABI version enum.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184267 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-19 00:55:23 +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
c2b6adff3e [yaml2obj][ELF] Don't monkeypatch the YAML sections.
Previously, we would monkeypatch the vector of YAML::Section's in order
to ensure that the SHT_NULL entry is present. Now we just add it
unconditionally.

The proliferation of small numerical adjustments is beginning to
frighten me, but I can't think of a way having a single point of truth
for them without introducing a whole new layer  of data structures (i.e.
lots of code and complexity) between the YAML and binary ELF formats.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184260 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 23:37:23 +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
Sean Silva
a7bd8549fd [yaml2obj][ELF] Add dummy .strtab section.
This will be needed later for holding symbol names, due to the libObject
issue mentioned in the commit message of r184161.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184242 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 21:37:50 +00:00
Sean Silva
c60c86dcae [yaml2obj][ELF] Factor out string table section creation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184162 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 01:11:27 +00:00
Sean Silva
7dc89c1f3a [yaml2obj][ELF] Refer specifically to the section header string table.
A bug in libObject will cause it to assert() if a symbol table's string
table and the section header string table are the same section, so we
need to ensure that we emit two different string tables (among other
things). The problematic code is the hardcoded usage of ".strtab"
(`dot_strtab_sec`) for looking up symbol names in
ELFObjectFile<ELFT>::getSymbolName.

I discussed this with Michael, and he has some local improvements to the
ELF code in libObject that, among other things, should fix our handling
of this scenario.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184161 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 01:11:24 +00:00
Sean Silva
13a8e2da76 [yaml2obj][ELF] Ensure more fields are zero'd.
I was spotting garbage in the output. I'd like to just zero the entire
ELFYAML::Section to be sure, but it contains non-POD types. (I'm also
trying to avoid bloating the ELFYAML::Foo classes with a bunch of
constructor code).

No test, since this is by its very nature unpredictable. I'm pretty sure
that one of the sanitizers would catch it immediately though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184160 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 01:11:21 +00:00
Sean Silva
4b548ecb01 [yaml2obj][ELF] Exit with error status on error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184115 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-17 20:14:59 +00:00
Sean Silva
f3f3523b9c [yaml2obj] Move some classes into anonymous namespaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184025 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-15 00:31:46 +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
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
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
Sean Silva
63958fba58 Add BinaryRef binary_size() method.
This avoids making assumptions about the data representation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183349 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 23:32:27 +00:00
Sean Silva
639adc59f8 Add writeAsBinary(raw_ostream &) method to BinaryRef.
Previously, yaml2coff.cpp had a writeHexData static helper function to
do this, but it is generally useful functionality.

Also, validate hex strings up-front to avoid running having to handle
errors "deep inside" the yaml2obj code (it also gives better diagnostics
than it used to).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183345 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 22:59:00 +00:00
Sean Silva
6ed30e0f0c yaml2obj: split out COFF logic into separate file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183335 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 19:56:47 +00:00
Sean Silva
db9dc53871 yaml2obj: add -format=<fmt> to choose input YAML interpretation
See the comment in yaml2obj.cpp for why this is currently needed.
Eventually we can get rid of this, but for now it is needed in order to
make forward progress with adding ELF support, and should be
straightforward to remove later.

Also, preserve the default of COFF, to avoid breaking existing tests.
This policy can easily be changed later though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183332 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 18:51:34 +00:00
Rafael Espindola
06120815a2 Rename COFFYaml.h to COFFYAML.h for consistency.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183042 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-31 20:38:27 +00:00
Rafael Espindola
05bc4a6f20 Don't allocate temporary string for section data.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183040 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-31 20:26:44 +00:00
Rafael Espindola
637cb17a3d Fix the configure build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182172 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-17 23:20:58 +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
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
Rafael Espindola
3d3cc32f5f Don't compute a std::vector<uint8_t> just to write it out a stream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180247 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-25 03:07:42 +00:00