Currently, llvm-readobj can dump symbol version sections only in LLVM style. In this patch, I would like to separate these dumpers into GNU style and
LLVM style for future implementation.
Details
- Reviewers
grimar jhenderson mattd rupprecht - Commits
- rGea16be1ca7e4: [llvm-readobj] Separate `Symbol Version` dumpers into `LLVM style` and `GNU…
rL356881: [llvm-readobj] Separate `Symbol Version` dumpers into `LLVM style` and `GNU…
rG94a0cffe250c: [llvm-readobj] Separate `Symbol Version` dumpers into `LLVM style` and `GNU…
rL356764: [llvm-readobj] Separate `Symbol Version` dumpers into `LLVM style` and `GNU…
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 29433 Build 29432: arc lint + arc unit
Event Timeline
Updating D59186: [llvm-readobj] Separate Symbol Version dumpers into LLVM style and GNU style
Are you definitely going to implement a GNU style after this? Otherwise, you've removed any form of support from the GNU dumper, without replacing it with something.
tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
3392–3393 | I think these unused named parameters might result in warnings on some build systems. Ditto below. | |
3394 | Here, and below, I don't think you should mention the section names, unless you have actually derived the names from the section passed in. | |
4524 | It may be worth factoring out this->dumper() into a local variable, since you use it in a number of places. | |
4555 | I know this was there before, but report_fatal_error is not a good way of reporting errors, since it implies an internal bug in LLVM. It should report a normal parse error or similar in the same way as other errors in llvm-readobj. Ditto below. I don't mind if it's in a follow-up patch though. |
Yes, I would like to implement these functions. But I'm afraid these functions make this patch too big. I would like to make these patches in series, so you could review them one by one.
I'll leave this to James. AFAIK he will do a BoF at LLVM 2019. I think
I need to listen to it to understand the desired direction of tools.
(splitting of formats is my concern)
BoFs are not usually recorded, I believe, but there will be a write-up published on llvm-dev hopefully after the event.
Addressed @jhenderson 's comments
It may be worth factoring out this->dumper() into a local variable, since you use it in a number of places.
Done
I know this was there before, but report_fatal_error is not a good way of reporting errors, since it implies an internal bug in LLVM. It should report a normal parse error or similar in the same way as other errors in llvm-readobj.
I would like to fix this issue here and that in LLVM style dumper in next patch
I implemented 3 dumpers for .gnu.version, .gnu.version_r, .gnu.version_d, with some small adjustments.
- GNU readelf treats 0x0 flags as none, so I add one in SymVersionFlags
- I separate getSymbolVersion into getSymbolVersion and getSymbolVersionByIndex. Because when dumping .gnu.version section, we should print symbol version for symbols that have valid version name.
However, there are some issues.
- Currently, when dumping .gnu.version_d section, we assume a symbol can have only one predecessor. But GNU readelf could dump these predecessors correctly.
- When dumping some fields that contains offset into string table, if the offset is invalid, GNU readelf could give warning, and give the malformed value.
Shall I separate this patch into several small patches?
I'm always in favour of splitting up changes into multiple smaller reviews, as long as it doesn't make things more complicated by requiring temporary logic or whatever that is just going to be removed again immediately. It'll hopefully help diffing the changes too.
Update.
Addressed @jhenderson 's comments.
- Using the actual section name.
- Add FIXME comments near report_fatal_error() (I would like to fix this in the future).
test/tools/yaml2obj/verdef-section.yaml | ||
---|---|---|
2 | These tests should -- temporarily -- run both llvm-readobj+llvm-readelf and verify it's the same (or at least the version sections match) (i.e. you probably can't cmp the whole thing like other tests do, but the same filecheck should work) |
Addressed @rupprecht 's comments.
- Add llvm-readelf to test cases.
I didn't modify the tests in tests/tools/yaml2obj, because I think those tests are for yaml2obj not llvm-readobj. Am I right?
I want to implement dumpers for these sections. In .gnu.version, we should print the version name of a versioning symbol, so I need a helper function to find the version name by its vs_index.
I'm happy with this, once my suggestions have been fixed.
test/tools/llvm-readobj/elf-versioninfo.test | ||
---|---|---|
83 | Nit: extra blank line. |
LGTM, with one last comment. Please wait for @rupprecht to confirm that he is happy.
tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
4524 | ELFDumper<ELFT> not auto |
test/tools/llvm-readobj/elf-versioninfo.test | ||
---|---|---|
6–118 | nit: use LLVM-VERDEF/GNU-VERDEF for consistent hyphens (e.g. LLVM_VERDEF-NEXT should be LLVM-VERDEF-NEXT) |
I am sorry, after reverting the change, I went to sleep last night ... I should have double checked this change.
Hi, @jhenderson, @rupprecht
I am sorry that this patch should be reviewed once again. I made a mistake in previous patch, which I will illustrate below.
tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
4534 | The version of a symbol in .gnu.version should be calculated using Versym->vs_index & VERSYM_VERSION (0x7fff). Before this patch, we use *VersymBuf as its version. I think it's not a right way, though it does the right thing in most time. |
test/tools/llvm-readobj/elf-versioninfo.test | ||
---|---|---|
119 | Nit: no newline at EOF. | |
test/tools/yaml2obj/verneed-section.yaml | ||
74 | Nit: missing new line at EOF here. | |
tools/llvm-readobj/ELFDumper.cpp | ||
4534 | I wasn't able to find any documentation for this outside of code, but I see that it is already used elsewhere in this file in a similar manner, and I found other examples of it in code elsewhere, so this looks fine to me. I'm not quite sure what you mean by:
Which way don't you think is right? What conditions does it do the right thin most of the time? |
tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
4534 |
I think using *VersymBuf is not a good way to indicate the symbol version, and we should use Versym->vs_index & VERSYM_VERSION. Usually, the version of a symbol should be a number that not so big. So, *VersymBuf (1 byte) should be equal to Versym->vs_index & VERSYM_VERSION (2 bytes). |
test/tools/llvm-readobj/elf-versioninfo.test | ||
---|---|---|
11 | This test file uses a pre-compiled object file, I want (replace this/add one test) using yaml2obj in next patch. |
Maybe you should make one of the symbols in this section have a version > 0x7fff, e.g. 0xffff?