I've noticed that it is not convenient to create YAMLs from
binaries (using obj2yaml) that have to be test cases for obj2yaml
later (after applying yaml2obj).
The problem, for example is that obj2yaml emits "DynamicSymbols:"
key instead of .dynsym. It also does not create .dynstr.
And when a YAML document without explicitly defined .dynsym/.dynstr
is given to yaml2obj, we have issues:
1) These sections are placed after non-allocatable sections (I've fixed it in D74756).
2) They have VA == 0. User needs create descriptions for such sections explicitly manually
to set a VA.
This patch addresses (2). I suggest to let yaml2obj assign virtual addresses by itself.
It makes an output binary to be much closer to "normal" ELF.
(It is still possible to use "Address: 0x0" for a section to get the original behavior
if it is needed)
Differential revision: https://reviews.llvm.org/D74764
The changes the in-memory representation of wasm symbols such that their
optional ImportName and ImportModule use llvm::Optional.
ImportName is set whenever WASM_SYMBOL_EXPLICIT_NAME flag is set.
ImportModule (for imports) is currently always set since it defaults to
"env".
In the future we can possibly extent to binary format distingish
import which have explit module names.
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74109
.dynsym and .dynstr are allocatable and therefore normally are placed
before non-allocatable .strtab, .shstrtab, .symtab sections.
But we are placing them after currently what creates a mix of
alloc/non-alloc sections and does not look normal.
Differential revision: https://reviews.llvm.org/D74756
There was a short discussion about this:
https://reviews.llvm.org/D73484#inline-676942
To summarize:
It is a bit unclear to me why the `DT_SYMENT` tag exist.
LLD has the code that does:
"addInt(DT_SYMENT, sizeof(Elf_Sym));" and I guess other linkers has the same logic.
It is unclear why it can be possible to have other values rather than values of
a size of platform symbol. Seems it is not possible, and atm for me it looks that
this tag should not be used. This patch starts reporting the warning when the
value it contains differs from a symbol size for a 32/64 bit platform for safety.
It keeps the rest of the logic we have unchanged. Before this patch we did not handle
the tag at all.
Differential review: https://reviews.llvm.org/D74479
This reverts commit 80a34ae31125aa46dcad47162ba45b152aed968d with fixes.
Previously, since bots turning on EXPENSIVE_CHECKS are essentially turning on
MachineVerifierPass by default on X86 and the fact that
inline-asm-avx-v-constraint-32bit.ll and inline-asm-avx512vl-v-constraint-32bit.ll
are not expected to generate functioning machine code, this would go
down to `report_fatal_error` in MachineVerifierPass. Here passing
`-verify-machineinstrs=0` to make the intent explicit.
This reverts commit 80a34ae31125aa46dcad47162ba45b152aed968d with fixes.
On bots llvm-clang-x86_64-expensive-checks-ubuntu and
llvm-clang-x86_64-expensive-checks-debian only,
llc returns 0 for these two tests unexpectedly. I tweaked the RUN line a little
bit in the hope that LIT is the culprit since this change is not in the
codepath these tests are testing.
llvm\test\CodeGen\X86\inline-asm-avx-v-constraint-32bit.ll
llvm\test\CodeGen\X86\inline-asm-avx512vl-v-constraint-32bit.ll
This reverts commit rGcd5b308b828e, rGcd5b308b828e, rG8cedf0e2994c.
There are issues to be investigated for polly bots and bots turning on
EXPENSIVE_CHECKS.
This adds a test to document --elf-cg-profile option we have.
I am going to refactor this area, and this patch is mostly to
create a base for a follow-up change.
Differential revision: https://reviews.llvm.org/D74115
When both little-endian and big-endian are tested, or both 32-bit and 64-bit are tested, use a template like the following with `-D BITS=32 -D ENCODE=LSB`
```
--- !ELF
FileHeader:
Class: ELFCLASS[[BITS]]
Data: ELFDATA2[[ENCODE]]
Type: ET_DYN
Machine: EM_X86_64
```
Reviewed By: grimar, jhenderson
Differential Revision: https://reviews.llvm.org/D73828
Previously the description allowed to describe symbols with use of
`Name` and `Index` keys. This patch removes them and now it is still
possible to use either names or symbol indexes, but the code is simpler
and the format is slightly different.
Such a change will be useful for another patches, e.g:
https://reviews.llvm.org/D73788#inline-671077
Differential revision: https://reviews.llvm.org/D73888
Currently when we dump dynamic relocation with use of
DT_RELA/DT_RELASZ/DT_RELAENT tags, we crash when a symbol index
is larger than the number of dynamic symbols or
when there is no dynamic symbol table.
This patch adds test cases and fixes the issues.
Differential revision: https://reviews.llvm.org/D73560
We have the `ELF\sections.test` to test --sections.
`ELF\sections.test` uses precompiled objects, it has a bug (does not test -s alias properly).
Also, we test machine specific section types in `ELF\machine-specific-section-types.test`,
so we probably do not need to test `--sections` for a MIPS object in `ELF\sections.test`.
I think it is enough to test ELF32 and ELF64 (we do not test ELF64 in this test).
`Object/readobj-shared-object.test` also tests how llvm-readobj handles
`--sections`. It is location is wrong, it is not complete, it uses precompiled binaries
and it duplicates the `ELF\sections.test` partially (it tests both ELF32 and ELF64).
We have `ELF\readelf-s-alias.test` that tests the `-s` alias for `--sections` in llvm-readobj
and `-s` as an alias for `--symbols` in llvm-readelf.
There is no need to have a separate test for such things.
The test for the `-s` alias for `--sections` can be included into the `ELF\sections.test`.
And the test for `-s` for llvm-readelf is already included into `ELF\symbols.test`.
So, this patch:
1) Removes `Object/readobj-shared-object.test`.
2) Removes `ELF\readelf-s-alias.test`
3) Rewrites the `ELF\sections.test`.
4) Removes ELF/Inputs/trivial.obj.elf-mipsel.
Differential revision: https://reviews.llvm.org/D73686
DynRegionInfo is a helper class used to create memory ranges.
It is used for many things and can report errors.
Errors reported currently do not provide a good diagnostic.
This patch fixes it and adds a test for each possible case.
Differential revision: https://reviews.llvm.org/D73484
The current implementation stops dumping in case of a single error
it handles, though we can continue dumping.
This patch refines it: it adds a few warnings and a few test cases.
Differential revision: https://reviews.llvm.org/D73269
The intention of Object/readobj-shared-object.test was to check the
general output for shared object.
I've added a case for testing dynamic objects to ELF/symbols.test.
Also we already test dynamic symbols printing in ELF/dyn-symbols.test +
I've added a case for `--dyn-syms` alias in D73164.
Hence we can remove this piece from Object/readobj-shared-object.test.
Differential revision: https://reviews.llvm.org/D73175
We have no good test for --needed-libs option.
The one we have as a part of Object/readobj-shared-object.test
is not complete.
In this patch I've did a minor NFC changes to the implementation and
added a test. This allowed to remove this piece from
Object/readobj-shared-object.test
Differential revision: https://reviews.llvm.org/D73174
It removes the Object/readobj-absent.test test and creates a one more case in
dyn-symbols.test we have.
Differential revision: https://reviews.llvm.org/D73169
We had no test for --hash-table in tools/llvm-readobj.
The one we had was in test/Object and checked that
it is possible to dump the hash table even when an object
doesn't have a section header table.
In this patch I created a test, moved and merged the existent one.
During moving I converted it to be YAML based to stop using the
precompiled binary.
Differential revision: https://reviews.llvm.org/D73105
We have a test/Object/no-section-header-string-table.test which checks
what happens when an object does not have a section header string table.
It does not check the full output though.
Currently our output is different from GNU readelf, because the latter prints
"<no-strings>" instead of a section name, while we print nothing.
This patch fixes this, adds a proper test case and removes the one from test/Object,
as it is not a right folder for llvm-readelf tests.
Differential revision: https://reviews.llvm.org/D73193
We have a `-dyn-symbols` option. It has a `--dyn-syms` alias
that is not tested in llvm-readobj tests currently.
There was a Object/readobj-elf-versioning.test where it is used,
but I've removed it in D73163. And also it is not the
right place to test it anyways.
Differential revision: https://reviews.llvm.org/D73164
To improve consistency and avoid unneeded shell feature (output
redirection).
While here, make other changes to improve consistency
--docnum 1 => --docnum=1
-docnum=x => --docnum=x
rpath.test checks that DT_RPATH is dumped.
We have dynamic-tags.test that tests all dynamic
tags and it is better, because also checks llvm-readelf
and does not use precompiled binaries.
Differential revision: https://reviews.llvm.org/D73093
This change is similar to one made for llvm-objdump in D72838.
llvm-readelf/llvm-readobj tools do not align the "Name/Value" column properly.
This patch adds a logic to calculate the size of indentation on fly
to fix such issues.
Differential revision: https://reviews.llvm.org/D72843
Summary:
This patch could be treated as a rebase of D33960. It also fixes PR35547.
A fix for `llvm/test/Other/close-stderr.ll` is proposed in D68164. Seems
the consensus is that the test is passing by chance and I'm not
sure how important it is for us. So it is removed like in D33960 for now.
The rest of the test fixes are just adding `--crash` flag to `not` tool.
** The reason it fixes PR35547 is
`exit` does cleanup including calling class destructor whereas `abort`
does not do any cleanup. In multithreading environment such as ThinLTO or JIT,
threads may share states which mostly are ManagedStatic<>. If faulting thread
tearing down a class when another thread is using it, there are chances of
memory corruption. This is bad 1. It will stop error reporting like pretty
stack printer; 2. The memory corruption is distracting and nondeterministic in
terms of error message, and corruption type (depending one the timing, it
could be double free, heap free after use, etc.).
Reviewers: rnk, chandlerc, zturner, sepavloff, MaskRay, espindola
Reviewed By: rnk, MaskRay
Subscribers: wuzish, jholewinski, qcolombet, dschuff, jyknight, emaste, sdardis, nemanjai, jvesely, nhaehnle, sbc100, arichardson, jgravelle-google, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, lenary, s.egerton, pzheng, cfe-commits, MaskRay, filcab, davide, MatzeB, mehdi_amini, hiraditya, steven_wu, dexonsmith, rupprecht, seiya, llvm-commits
Tags: #llvm, #clang
Differential Revision: https://reviews.llvm.org/D67847
After recent changes (D71872) in yaml2obj, it is possible so cleanup
testing of the SHT_RELR sections.
Differential revision: https://reviews.llvm.org/D71874
This adds a few more tests for dynamic section.
We only had tests for simple unknown values for 64-bits target,
in this patch I've added OS specific and processor specific tags.
Also it tests both 32 and 64-bits targets now.
It will help to fix the formatting issues we have and diagnose a possible new ones.
Differential revision: https://reviews.llvm.org/D71896
This adds --strict-whitespace --match-full-lines flags to
improve the testing and reveal formatting issues we have.
Differential revision: https://reviews.llvm.org/D71895
This cleans up and merges `gnu-symbols.test` to `symbols.test`.
Initially `gnu-symbols.test` tested the following things:
1) How symbols are printed in GNU style.
It does not make sense to have a separate file for such tests.
2) It tried to test proc-specific symbol indexes. The test was incomplete and
also we already have `symbol-shndx.test` for that, so this part was removed.
3) It tested `--dyn-symbols` and `--symbols` correlation. All following
cases were moved to `symbols.test`:
a) That `--dyn-symbols` does not trigger showing regular symbols..
b) That `--symbols` triggers `--dyn-symbols` implicitly.
c) That `--dyn-symbols` and `--symbols` works fine together.
Differential revision: https://reviews.llvm.org/D71697
This removes the `getTypeString` from readeobj source because it
almost duplicates the existent method: `ELFFile<ELFT>::getDynamicTagAsString`.
Side effect: now it prints "<unknown:>0xHEXVALUE" instead of "(unknown)" for unknown values.
llvm-readelf before this patch printed:
```
0x0000000012345678 (unknown) 0x8765432187654321
0x000000006abcdef0 (unknown) 0x9988776655443322
0x0000000076543210 (unknown) 0x5555666677778888
```
and now it prints:
```
0x0000000012345678 (<unknown:>0x12345678) 0x8765432187654321
0x000000006abcdef0 (<unknown:>0x6abcdef0) 0x9988776655443322
0x0000000076543210 (<unknown:>0x76543210) 0x5555666677778888
```
GNU reaedlf prints different thing:
```
0x0000000012345678 (<unknown>: 12345678) 0x8765432187654321
0x000000006abcdef0 (Operating System specific: 6abcdef0) 0x9988776655443322
0x0000000076543210 (Processor Specific: 76543210) 0x5555666677778888
```
I am not sure we want to follow GNU here. Even if we do, it should be separate
patch probably. The new output looks better and closer to GNU anyways,
and the code is a bit simpler.
Differential revision: https://reviews.llvm.org/D71835
This rewrites a few tests to stop using the
trivial.obj.elf-x86-64 precompiled object
and removes it.
Differential revision: https://reviews.llvm.org/D71662
This removes the precompiled binary used, simplifies
the first test case, adds comments and llvm-readelf tool
invocations.
It also adds a test case for checking versioning symbols.
Differential revision: https://reviews.llvm.org/D71595
This removes 2 precompiled binaries, adds testing
for STO_* flags missing, refines and renames the test.
Differential revision: https://reviews.llvm.org/D71651
We have the `elf-dynamic-tags-machine-specific.yaml` input shared
between the llvm-readobj and llvm-objdump test.
It looks strange, because tools usually does not share inputs.
Also there are following problems related:
1) `elf-dynamic-tags-machine-specific.yaml` input contains excessive YAML parts.
2) objdump's test case never test AARCH64 tags.
3) There are unknown tags in the `elf-dynamic-tags-machine-specific.yaml` and
`dynamic-tags-machine-specific.test`, though we already testing unknown tags
in `\llvm-readobj\ELF\dynamic-tags.test` and `llvm-objdump\elf-dynamic-section.test` tests.
This patch removes the shared input and refines the test cases to resolve
issues mentioned.
Differential revision: https://reviews.llvm.org/D71602
In this test case we use 3 precompiled objects to
test how we print a histogram for an GNU hash section.
It does not make sense to use precompiled objects
for that. Also we could have 2 tests: one for 32 and
another for 64 bits target.
This patch does this change. It is not possible to remove
these precompiled objects because they are used elsewhere.
Differential revision: https://reviews.llvm.org/D71606
GNU uses `l` for SHF_X86_64_LARGE and `y` for SHF_ARM_PURECODE.
Lets follow.
To do this I had to refactor and refine how we print the help flags description.
It was too generic and inconsistent with GNU readelf.
Differential revision: https://reviews.llvm.org/D71464
Our logic that dumped the flags was buggy.
For LLVM style it dumped SHF_MASKPROC/SHF_MASKOS named constants, though
they are not flags, but masks.
For GNU style it was just very inconsistent with GNU which has logic
that is not straightforward. Imagine we have sh_flags == 0x90000000.
SHF_EXCLUDE ("E") has a value of 0x80000000 and SHF_MASKPROC is 0xf0000000.
GNU readelf will not print "E" or "Ep" in this case, but will print just
"p". It only will print "E" when no other processor flag is set.
I had to investigate the GNU source to find the algorithm and now our logic should
match it.
Differential revision: https://reviews.llvm.org/D71462