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

71 Commits

Author SHA1 Message Date
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
Hans Wennborg
1f76d4c2b7 ELFObjectWriter: deduplicate suffices in strtab
We already do this for shstrtab, so might as well do it for strtab. This
extracts the string table building code into a separate class. The idea
is to use it for other object formats too.

I mostly wanted to do this for the general principle, but it does save a
little bit on object file size. I tried this on a clang bootstrap and
saved 0.54% on the sum of object file sizes (1.14 MB out of 212 MB for
a release build).

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

llvm-svn: 207670
2014-04-30 16:25:02 +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
Simon Atanasyan
cef01b6971 [yaml2obj][ELF] Rename class SectionNameToIdxMap => NameToIdxMap. It can
be used for indexing not only section's names.

No functional changes.

llvm-svn: 205687
2014-04-06 09:02:55 +00:00
Simon Atanasyan
3df8961578 [yaml2obj][ELF] Convert some static functions into class members to
reduce number of arguments.

No functional changes.

llvm-svn: 205434
2014-04-02 16:34:54 +00:00
Simon Atanasyan
df3465ac4a [yaml2obj][ELF] Remove unused typedef.
No functional changes.

llvm-svn: 205433
2014-04-02 16:34:48 +00:00
Simon Atanasyan
36b72be52e [yaml2obj][ELF] Move section index to the ELFState class.
No functional changes.

llvm-svn: 205432
2014-04-02 16:34:40 +00:00
Simon Atanasyan
af3e6497c2 [yaml2obj][ELF] Remove relationship between ELFState
and ContiguousBlobAccumulator classes. Pass ContiguousBlobAccumulator to
the handleSymtabSectionHeader function directly.

No functional changes.

llvm-svn: 205431
2014-04-02 16:34:34 +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
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
1c14eb4e87 [yaml2obj][ELF] Use range-based for loops.
llvm-svn: 203900
2014-03-14 06:53:30 +00:00
Simon Atanasyan
105d79c61c [yaml2obj][ELF] Refer to a section in the error message by its name not
index.

llvm-svn: 203899
2014-03-14 06:53:25 +00:00
Simon Atanasyan
d6444df5cd [yaml2obj][ELF] Remove unused ELFState class field.
llvm-svn: 203898
2014-03-14 06:53:21 +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
Ahmed Charles
52ce0c101e Replace OwningPtr<T> with std::unique_ptr<T>.
This compiles with no changes to clang/lld/lldb with MSVC and includes
overloads to various functions which are used by those projects and llvm
which have OwningPtr's as parameters. This should allow out of tree
projects some time to move. There are also no changes to libs/Target,
which should help out of tree targets have time to move, if necessary.

llvm-svn: 203083
2014-03-06 05:51:42 +00:00
NAKAMURA Takumi
084aff62e6 llvm/tools: Prune redundant target_link_libraries.
llvm-svn: 200559
2014-01-31 17:40:06 +00:00
NAKAMURA Takumi
955efe24ce [CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt.
llvm-svn: 196908
2013-12-10 11:13:32 +00:00
Will Dietz
be3a7e9197 yaml2coff/elf: Touchup for compatibility.
* std::string::append(int, int) can be ambiguous.
* std::vector<>::data() is a C++11 feature, use ArrayRef abstraction.

llvm-svn: 192542
2013-10-12 21:29:16 +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
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
ced30f0888 [yaml2obj][ELF] Narrow parameter.
The full ELFYAML::Section isn't needed.

llvm-svn: 184626
2013-06-22 01:37:55 +00:00
Sean Silva
6c026a5822 [yaml2obj][ELF] Don't special case writing these.
Just add them to the vector of section headers like the rest of the
section headers.

llvm-svn: 184624
2013-06-22 01:06:12 +00:00
Sean Silva
1a38fd79ca [yaml2obj][ELF] Make this "type switch" actually readable.
llvm-svn: 184623
2013-06-22 01:03:35 +00:00
Sean Silva
e017a5d29f [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.

llvm-svn: 184621
2013-06-22 00:47:43 +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
c04d8ed7be Unbreak bots. Didn't realize this was a C++11 feature.
llvm-svn: 184508
2013-06-21 00:33:01 +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
Sean Silva
b36f148890 [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.

llvm-svn: 184467
2013-06-20 20:59:34 +00:00
Sean Silva
8006fd36a5 [yaml2obj][ELF] Start factoring into "single point of truth".
llvm-svn: 184457
2013-06-20 19:11:44 +00:00
Sean Silva
459731fae0 [yaml2obj][ELF] Just let this class own its buffer.
llvm-svn: 184456
2013-06-20 19:11:41 +00:00
Sean Silva
b0fb5cb3dc Remove using namespace and use explicit qualification.
There were only two places it was actually making anything shorter.

llvm-svn: 184273
2013-06-19 01:13:28 +00:00
Sean Silva
c542be787e Remove spurious space.
llvm-svn: 184272
2013-06-19 01:10:58 +00:00
Sean Silva
e9371a8a2c Remove unused parameter.
Not sure why we weren't catching this with -Wunused-parameter...

Spotted by inspection.

llvm-svn: 184271
2013-06-19 01:10:11 +00:00
Sean Silva
a39ac0fdeb [yaml2obj][ELF] Support ELFOSABI_* enum.
llvm-svn: 184268
2013-06-19 00:55:28 +00:00
Sean Silva
5b5567b80b There is no ELF ABI version enum.
llvm-svn: 184267
2013-06-19 00:55:23 +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
af68c9e26b [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.

llvm-svn: 184260
2013-06-18 23:37:23 +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
Sean Silva
396d02068a [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.

llvm-svn: 184242
2013-06-18 21:37:50 +00:00
Sean Silva
2bfc77ced4 [yaml2obj][ELF] Factor out string table section creation.
llvm-svn: 184162
2013-06-18 01:11:27 +00:00
Sean Silva
034418b820 [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.

llvm-svn: 184161
2013-06-18 01:11:24 +00:00
Sean Silva
5a0f79505b [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.

llvm-svn: 184160
2013-06-18 01:11:21 +00:00
Sean Silva
914b2119ec [yaml2obj][ELF] Exit with error status on error.
llvm-svn: 184115
2013-06-17 20:14:59 +00:00
Sean Silva
2b8e17f6e5 [yaml2obj] Move some classes into anonymous namespaces.
llvm-svn: 184025
2013-06-15 00:31:46 +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