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

1555 Commits

Author SHA1 Message Date
Georgii Rymar
f2d8b0a536 [llvm-readobj] - Make decode_relrs() don't return Expected<>. NFCI.
The `decode_relrs` helper is declared as:

`Expected<std::vector<Elf_Rel>> decode_relrs(Elf_Relr_Range relrs) const;`

it never returns an error though and hence can be simplified to return
a vector.

Differential revision: https://reviews.llvm.org/D85302
2020-08-05 17:05:47 +03:00
Sameer Arora
fccf62295c [llvm-libtool-darwin] Refactor Slice and writeUniversalBinary
Refactoring `Slice` class and function `createUniversalBinary` from
`llvm-lipo` into  MachOUniversalWriter. This refactoring is necessary so
as to use the refactored code for creating universal binaries under
llvm-libtool-darwin.

Reviewed by alexshap, smeenai

Differential Revision: https://reviews.llvm.org/D84662
2020-07-31 09:22:35 -07:00
Georgii Rymar
e4864223fe [llvm-readobj] - Refactor how the code dumps relocations.
There is a strange "feature" of the code: it handles all relocations as `Elf_Rela`.
For handling `Elf_Rel` it converts them to `Elf_Rela` and passes `bool IsRela` to
specify the real type everywhere.

A related issue is that the
`decode_relrs` helper in lib/Object has to return `Expected<std::vector<Elf_Rela>>`
because of that, though it could return a vector of `Elf_Rel`.

I think we should just start using templates for relocation types, it makes the code
cleaner and shorter. This patch does it.

Differential revision: https://reviews.llvm.org/D83871
2020-07-20 12:05:05 +03:00
Fangrui Song
512d666f40 [DebugInfo] Respect relocations when decoding DW_EH_PE_sdata4 & DW_EH_PE_sdata8 and support R_ARM_REL32
The addresses in llvm-dwarfdump --eh-frame output for object files are closer to readelf -wf output now.
2020-07-18 09:00:50 -07:00
Fangrui Song
6d196aebc6 [RelocationResolver] Support R_AARCH64_PREL32
Code from D83800 by Yichao Yu
2020-07-17 23:49:15 -07:00
Fangrui Song
07079947f8 [RelocationResolver] Support R_PPC_REL32 & R_PPC64_REL{32,64}
This suppresses `failed to compute relocation: R_PPC_REL32, Invalid data was encountered while parsing the file`
and its 64-bit variants when running llvm-dwarfdump on a PowerPC object file with .eh_frame

Unfortunately it is difficult to test the computation:
DWARFDataExtractor::getEncodedPointer does not use the relocated value
and even if it does, we need to teach llvm-dwarfdump --eh-frame to do
some linker job to report a reasonable address.
2020-07-17 23:29:50 -07:00
Wouter van Oortmerssen
dbcc53b15e [WebAssembly] 64-bit (function) pointer fixes.
Accounting for the fact that Wasm function indices are 32-bit, but in wasm64 we want uniform 64-bit pointers.
Includes reloc types for 64-bit table indices.

Differential Revision: https://reviews.llvm.org/D83729
2020-07-16 14:10:22 -07:00
Wouter van Oortmerssen
53d8604583 [WebAssembly] Triple::wasm64 related cleanup
Differential Revision: https://reviews.llvm.org/D83713
2020-07-16 12:01:10 -07:00
Wouter van Oortmerssen
2d660a98ce [WebAssembly] 64-bit memory limits 2020-07-06 12:40:45 -07:00
Hans Wennborg
d489f3e1d7 [ThinLTO] Always parse module level inline asm with At&t dialect (PR46503)
clang-cl passes -x86-asm-syntax=intel to the cc1 invocation so that
assembly listings produced by the /FA flag are printed in Intel dialect.
That flag however should not affect the *parsing* of inline assembly in
the program. (See r322652)

When compiling normally, AsmPrinter::emitInlineAsm is used for
assembling and defaults to At&t dialect. However, when compiling for
ThinLTO, the code which parses module level inline asm to find symbols
for the symbol table was failing to set the dialect. This patch fixes
that. (See the bug for more details.)

Differential revision: https://reviews.llvm.org/D82862
2020-07-01 09:43:45 +02:00
Simon Pilgrim
139cbe87ac Error.h - GenericBinaryError - pass Twine arg by reference not value.
This allows us to reduce the Twine.h include to a forward declaration.
2020-06-27 10:12:20 +01:00
Eli Friedman
9d315e1c2b Remove GlobalValue::getAlignment().
This function is deceptive at best: it doesn't return what you'd expect.
If you have an arbitrary GlobalValue and you want to determine the
alignment of that pointer, Value::getPointerAlignment() returns the
correct value.  If you want the actual declared alignment of a function
or variable, GlobalObject::getAlignment() returns that.

This patch switches all the users of GlobalValue::getAlignment to an
appropriate alternative.

Differential Revision: https://reviews.llvm.org/D80368
2020-06-23 19:13:42 -07:00
Sam Clegg
41b638ec50 [WebAssembly] Add support for externalref to MC and wasm-ld
This allows code for handling externref values to be processed by the
assembler and linker.

Differential Revision: https://reviews.llvm.org/D81977
2020-06-22 15:57:24 -07:00
Anatoly Trosinenko
b2e4c430fd [MSP430] Enable some basic support for debug information
This commit technically permits LLVM to emit the debug information for ELF files for MSP430 architecture. Aside from this, it only defines the register numbers as defined by part 10.1 of MSP430 EABI specification (assuming the 1-byte subregisters share the register numbers with corresponding full-size registers).

This commit was basically tested by me with TI-provided GCC 8.3.1 toolchain by compiling an example program with `clang` (please note manual linking may be required due to upstream `clang` not yet handling the `-msim` option necessary to run binaries on the GDB-provided simulator) and then running it and single-stepping with `msp430-elf-gdb` like this:

```
$sysroot/bin/msp430-elf-gdb ./test -ex "target sim" -ex "load ./test"
(gdb) ... traditional GDB commands follow ...
```

While this implementation is most probably far from completeness and is considered experimental, it can already help with debugging MSP430 programs as well as finding issues in LLVM debug info support for MSP430 itself.

One of the use cases includes trying to find a point where UBSan check in a trap-on-error mode was triggered.

The expected debug information format is described in the [MSP430 Embedded Application Binary Interface](http://www.ti.com/lit/an/slaa534/slaa534.pdf) specification, part 10.

Differential Revision: https://reviews.llvm.org/D81488
2020-06-22 13:14:07 +03:00
Wouter van Oortmerssen
2eaa4e6cf6 [WebAssembly] Adding 64-bit version of R_WASM_MEMORY_ADDR_* relocs
This adds 4 new reloc types.

A lot of code that previously assumed any memory or offset values could be contained in a uint32_t (and often truncated results from functions returning 64-bit values) have been upgraded to uint64_t. This is not comprehensive: it is only the values that come in contact with the new relocation values and their dependents.

A new tablegen mapping was added to automatically upgrade loads/stores in the assembler, which otherwise has no way to select for these instructions (since they are indentical other than for the offset immediate). It follows a similar technique to https://reviews.llvm.org/D53307

Differential Revision: https://reviews.llvm.org/D81704
2020-06-15 10:07:42 -07:00
Jonas Devlieghere
1576d70a23 [llvm/Object] Reimplment basic_symbol_iterator in TapiFile
Use indices into the Symbols vector instead of casting the objects in
the vector and dereferencing std::vector::end().

This change is NFC modulo the Windows failure reported by
llvm-clang-x86_64-expensive-checks-win.

Differential revision: https://reviews.llvm.org/D81717
2020-06-12 00:03:32 -07:00
Cyndy Ishida
fd46376e35 [llvm][llvm-nm] add TextAPI/MachO support
Summary:
This completes the needed glueing to support reading tbd files from nm.
This includes specifying which slice filtering with `--arch` and a new
option specifically for tbd files `--add-inlinedinfo` which will show
the reexported libraries that are appended in the tbd file.

Reviewers: ributzka, steven_wu, JDevlieghere, jhenderson

Reviewed By: JDevlieghere

Subscribers: hiraditya, MaskRay, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81614
2020-06-11 18:54:16 -07:00
Reid Kleckner
6a61ba0a54 Re-land "Migrate the rest of COFFObjectFile to Error"
This reverts commit 101fbc01382edd89ea7b671104c68b30b2446cc0.

Remove leftover debugging attribute.

Update LLDB as well, which was missed before.
2020-06-11 14:46:16 -07:00
jasonliu
124e022860 [XCOFF][AIX] report_fatal_error when an overflow section is needed
If there are more than 65534 relocation entries in a single section,
we should generate an overflow section.
Since we don't support overflow section for now, we should generate
an error.

Differential revision: https://reviews.llvm.org/D81104
2020-06-08 19:59:04 +00:00
Nico Weber
e905d3fcf1 Revert "Migrate the rest of COFFObjectFile to Error"
This reverts commit b5289656b865d2a73cf90819e20a96fb8414ab0b.
__attribute__((optnone)) doesn't build with msvc, see
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/16326
2020-06-05 21:20:11 -04:00
Reid Kleckner
ce815b34d8 Migrate the rest of COFFObjectFile to Error 2020-06-05 16:29:05 -07:00
Reid Kleckner
ef44ae63c3 Re-land "Migrate Binary::checkOffset from error_code to Error, NFC"
This reverts commit 38f3ba591e3a64fa5bbe684b3171c7bda6c5b527.

Fix the XCOFF error handling. Unlike std::error_code, Error must be
consumed or handled.
2020-06-05 16:27:31 -07:00
Nico Weber
f5df235a15 Revert "Migrate Binary::checkOffset from error_code to Error, NFC"
This reverts commit 74bd98829d82312676a60c5c2d142e20691b2f13.
Breaks LLVM::section-headers.test everywhere, see e.g.
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/29940/steps/test-check-all/logs/FAIL%3A%20LLVM%3A%3Asection-headers.test
2020-06-05 17:00:20 -04:00
Reid Kleckner
e6bc3cf27d Migrate Binary::checkOffset from error_code to Error, NFC
In my use case, this saved 100ms of time doing one-time-initialization
for std::error_code().
2020-06-05 13:38:56 -07:00
Simon Pilgrim
5b2222b080 SymbolicFile.h - removed unused FileSystem.h include. NFC.
Exposes a number of implicit dependencies that needs fixing in source files and XCOFFObjectFile.h.
2020-05-28 15:26:31 +01:00
Kazushi (Jam) Marukawa
3398257fcd [VE] Implements minimum MC layer for VE (3/4)
Summary:
Define ELF binary code for VE and modify code where should use this new code.

Depends on D79544.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D79545
2020-05-28 10:07:48 +02:00
Simon Pilgrim
86bee611f2 ObjectFile.h - reduce unnecessary includes to forward declarations. NFC.
Fix SubtargetFeature.h include dependency in XCOFFObjectFile.cpp
2020-05-27 14:02:14 +01:00
Xing GUO
0c2e5066e9 [Object] Remove unused variable after D79560. NFC. 2020-05-11 13:03:53 +08:00
Reid Kleckner
a784878918 [COFF] Use Expected in COFFObjectFile creation
The constructor error out parameter was a bit awkward. Wrap it in a
factory method which can return an error. Make the constructor private.
2020-05-08 14:22:28 -07:00
Reid Kleckner
24ad5a39c5 [COFF] Migrate COFFObjectFile to Expected<T>
I noticed that std::error_code() does one-time initialization. Avoid
that overhead with Expected<T> and llvm::Error. Also, it is consistent
with the virtual interface and ELF, and generally cleaner.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D79643
2020-05-08 14:01:39 -07:00
Xing GUO
6b4b8c1713 [Object] Remove unneeded check in ELFFile<ELFT>::dynamicEntries().
Check for `DynSecSize % sizeof(Elf_Dyn) != 0` is unneeded in this context.

1. If the .dynamic section is acquired from program headers, the .dynamic
section is "cut off" by

```
makeArrayRef(..., Phdr.p_filesz / sizeof(Elf_Dyn));
DynSeSize = Phdr.p_filesz;
```

2. If the .dynamic section is acquired from section headers, the .dynamic
section is checked in `getSectionContentsAsArray<Elf_Dyn>(&Sec)`.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D79560
2020-05-08 09:54:36 +08:00
Xing GUO
0cc48af0ab [Object] Change ObjectFile::getSymbolValue() return type to Expected<uint64_t>
Summary:
In D77860, we have changed `getSymbolFlags()` return type to `Expected<uint32_t>`.
This change helps bubble the error further up the stack.

Reviewers: jhenderson, grimar, JDevlieghere, MaskRay

Reviewed By: jhenderson

Subscribers: hiraditya, MaskRay, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79075
2020-05-02 14:04:44 +08:00
Simon Pilgrim
b83ec4f3c2 RecordStreamer.h - cleanup includes and forward declarations. NFC.
Reduce MCSymbol.h include to forward declaration.
Remove unused GlobalValue foward declaration.
2020-04-22 15:07:18 +01:00
vgxbj
bbdc25ab11 [Object] Change uint32_t getSymbolFlags() to Expected<uint32_t> getSymbolFlags().
This change enables getSymbolFlags() to return errors which benefit error reporting in clients.

Differential Revision: https://reviews.llvm.org/D77860
2020-04-18 21:27:57 +08:00
Wouter van Oortmerssen
2d2a0b49b2 [WebAssembly] Add int32 DW_OP_WASM_location variant
This to allow us to add reloctable global indices as a symbol.
Also adds R_WASM_GLOBAL_INDEX_I32 relocation type to support it.

See discussion in https://github.com/WebAssembly/debugging/issues/12
2020-04-16 16:32:17 -07:00
Sam Clegg
bf755d5160 Enable finding bitcode in wasm objects
This commit fixes using functions in `IRObjectFile` to load bitcode from
wasm objects by recognizing the file magic for wasm and also inheriting
the default implementation of classifying sections as bitcode.

Patch By: alexcrichton

Differential Revision: https://reviews.llvm.org/D78199
2020-04-15 12:33:33 -07:00
Mehdi Amini
e27edda00f Revert "Move ModuleSummaryAnalysis from libAnalysis to libObject to break the dependency from Analysis to Object"
This reverts commit 10df1563d608323a3144afc5f6038ecb81869b92.

Some buildbots are broken.
2020-04-14 00:27:08 +00:00
Mehdi Amini
c54ae056de Move ModuleSummaryAnalysis from libAnalysis to libObject to break the dependency from Analysis to Object
ModuleSummaryAnalysis is the only file in libAnalysis that brings a
dependency on the CodeGen layer from libAnalysis, moving it breaks this
dependency.

Differential Revision: https://reviews.llvm.org/D77994
2020-04-13 23:12:11 +00:00
Jessica Clarke
42860b1380 [RISCV] Consume error from parsing attributes section
Summary:
We don't consume the error from getBuildAttributes, so an assertions
build crashes with "Program aborted due to an unhandled Error:".
Explicitly consume it like the ARM version in that case.

Reviewers: asb, jhenderson, MaskRay, HsiangKai

Reviewed By: MaskRay

Subscribers: kristof.beyls, hiraditya, simoncook, kito-cheng, shiva0217, rogfer01, rkruppe, psnobl, benna, Jim, lenary, s.egerton, sameer.abuasal, luismarques, evandro, danielkiss, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77841
2020-04-10 15:05:53 +01:00
diggerlin
94db89b3ba [llvm-objdump][XCOFF] Use symbol index+symbol name + storage mapping class as label for -D
SUMMARY:

For the llvm-objdump -D, the symbol name is used as a label in the disassembly for the specific address (when a symbol address is equal to the virtual address in the dump).

In XCOFF, multiple symbols may have the same name, being differentiated by their storage mapping class. It is helpful to print the QualName and not just the name when forming the output label for a csect symbol. The symbol index further removes any ambiguity caused by duplicate names.

To maintain compatibility with the binutils objdump, the XCOFF-specific --symbol-description option is added to enable the enhanced format.

Reviewers: hubert.reinterpretcast, James Henderson, Jason Liu ,daltenty
Subscribers: wuzish, nemanjai, hiraditya

Differential Revision: https://reviews.llvm.org/D72973
2020-04-06 10:10:10 -04:00
Djordje Todorovic
df20828951 [Object] Add the method for checking if a section is a debug section
Different file formats have different naming style for the debug
sections. The method is implemented for ELF, COFF and Mach-O formats.

Differential Revision: https://reviews.llvm.org/D76276
2020-04-02 10:56:00 +02:00
Hubert Tong
2ce03d64ef [Object] Update ObjectFile::makeTriple for XCOFF
Summary:
When we encounter an XCOFF file, reflect that in the triple information.
In addition to knowing the object file format, we know that the
associated OS is AIX.

This means that we can expect that there is no output difference in the
processing of an XCOFF32 input file between cases where the triple is
left unspecified by the user and cases where the user specifies
`--triple powerpc-ibm-aix` explicitly.

Reviewers: jhenderson, sfertile, jasonliu, daltenty

Reviewed By: jasonliu

Subscribers: wuzish, nemanjai, hiraditya, MaskRay, rupprecht, steven.zhang, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77025
2020-03-31 17:26:30 -04:00
Kai Wang
055a23f745 [RISCV] ELF attribute section for RISC-V.
Leverage ARM ELF build attribute section to create ELF attribute section
for RISC-V. Extract the common part of parsing logic for this section
into ELFAttributeParser.[cpp|h] and ELFAttributes.[cpp|h].

Differential Revision: https://reviews.llvm.org/D74023
2020-03-31 16:16:19 +08:00
jasonliu
f37e3c14a5 [llvm-objdump][XCOFF][AIX] Implement -r option
Summary:
Implement several XCOFF hooks to get '-r' option working for llvm-objdump -r.

Reviewer: DiggerLin, hubert.reinterpretcast, jhenderson, MaskRay

Differential Revision: https://reviews.llvm.org/D75131
2020-03-27 16:05:42 +00:00
Georgii Rymar
efc3ed36c5 [llvm-readobj] - Fix a crash when DT_STRTAB is broken.
We might have a crash scenario when we have an invalid DT_STRTAB value
that is larger than the file size. I've added a test case to demonstrate.

Differential revision: https://reviews.llvm.org/D76706
2020-03-27 13:18:08 +03:00
Heejin Ahn
58a2f8e25d [WebAssembly] Move event section before global section
Summary:
https://github.com/WebAssembly/exception-handling/issues/98

Also this moves many parts of code to make code align with the section
order, even if they don't affect the output.

Reviewers: tlively

Subscribers: dschuff, sbc100, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76752
2020-03-25 11:49:03 -07:00
Reid Kleckner
61b0badcbd Drop a StringMap.h include, NFC
$ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \
    | grep '^[-+] ' | sort | uniq -c | sort -nr
    231 -    llvm/include/llvm/ADT/StringMap.h
    171 -    llvm/include/llvm/Support/AllocatorBase.h
    142 -    llvm/include/llvm/Support/PointerLikeTypeTraits.h
2020-03-11 15:45:34 -07:00
James Henderson
a17a111e61 [Object] Fix handling of large archive members
The archive library truncated the size of archive members whose size was
greater than max uint32_t. This patch fixes the issue and adds some unit
tests to verify.

Reviewed by: ruiu, MaskRay, grimar, rupprecht

Differential Revision: https://reviews.llvm.org/D75742
2020-03-11 10:29:45 +00:00
Fangrui Song
02300509f3 [ARM] Rewrite ARMAttributeParser
* Delete boilerplate
* Change functions to return `Error`
* Test parsing errors
* Update callers of ARMAttributeParser::parse() to check the `Error` return value.

Since this patch touches nearly everything in the file, I apply
http://llvm.org/docs/Proposals/VariableNames.html and change variable
names to lower case.

Reviewed By: compnerd

Differential Revision: https://reviews.llvm.org/D75015
2020-03-05 10:57:27 -08:00
Michael Trent
4f4788bcfc Fix dyld opcode *_ADD_ADDR_IMM_SCALED error detection.
Summary:
Move the check for malformed REBASE_OPCODE_ADD_ADDR_IMM_SCALED and
BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED opcodes after the immediate
has been applied to the SegmentOffset. This fixes specious errors
where SegmentOffset is pointing between two sections when trying to
correct the SegmentOffset value.

Update the regression tests to verify the proper error message.

Reviewers: pete, ab, lhames, steven_wu, jhenderson

Reviewed By: pete

Subscribers: hiraditya, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75629
2020-03-04 19:57:45 -08:00