This adds functionality to readelf/readobj to specifically handle
MTE-related bits, like the AARCH64_MEMTAG_* dynamic entries, and a
decoder for the Android-specific ELF note.
Details
- Reviewers
fmayer jhenderson MaskRay - Commits
- rGa4d39d4b69b2: [llvm-readobj] Add --memtag
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
5952 | AFAICT this doesn't actually print anything, so this is a bit awkward. But maybe that's easier than manually iterating? At least worth a comment IMO. |
llvm/test/tools/llvm-readobj/ELF/AArch64/note-android-memtag.test | ||
---|---|---|
0 | Add a test when no memtag tag is present in an object file. | |
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
5239 | If the user specifies --memtag, Memtag Dynamic Entries: should be unconditionally printed, even if empty. | |
5241 | ||
5930 | delete this blank line | |
7308 | unconditionally print "Memtag Dynamic Entries:" | |
7311 | delete braces | |
llvm/tools/llvm-readobj/Opts.td | ||
58 | Does the help message include notes? I only see modes and global descriptors. |
llvm/test/tools/llvm-readobj/ELF/AArch64/memtag-missing.test | ||
---|---|---|
5 ↗ | (On Diff #497018) | |
7 ↗ | (On Diff #497018) | Should this be a CHECK-NEXT? |
13 ↗ | (On Diff #497018) | There's no point in the duplicate CHECK-NOT. What are you trying to test with these lines? |
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
301 | Any reason this can't be an ArrayRef<std::pair<std::string, std::string>> or similar? It may also be more self-documenting to use a two-field class instead of std::pair<std::string, std::string>, as you can then give the fields specific names. | |
2274 | This should be using Twine for the string concatenation. | |
2284 | Ditto. | |
2287 | Ditto. Also, the style for inline comments that are labelling a parameter is /*LowerCase=*/true. I believe the trailing = causes clang-format to format it like this. | |
5241 | Especially if you adopt my suggestion about adding a struct/class for the fields, you shouldn't use auto here in the loop (see Coding Standards about use of auto - it's not clear what the type is from the context). | |
5930 |
| |
5938–5939 | As above, do you need to use this->? | |
5952 | Seems to me like printNotesHelper might need renaming or restructuring. | |
7311 | As above re. auto. |
Update with jhenderson@'s comments: used arrayref in place of vector, some minor reformatting and renaming.
llvm/test/tools/llvm-readobj/ELF/AArch64/memtag-missing.test | ||
---|---|---|
13 ↗ | (On Diff #497018) | Removed the duplicate. We're trying to assert (unlike in memtag.test) that readelf/readobj --memtag indiscriminately prints "Memtag Dynamic Entries", but doesn't print a missing Android ELF note. |
llvm/test/tools/llvm-readobj/ELF/AArch64/note-android-memtag.test | ||
0 | done, in a separate file (memtag-missing.test) | |
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
301 | I've changed it to ArrayRef in the callees, but I'm don't think adding a struct for a pair of strings would drastically improve readability here. | |
5241 | I've updated all the range-based loops to use const auto& DynamicEntryKV (note the new KV suffix). I agree with you (and the style guide) on "avoid auto for non-obvious type deductions", but IMHO using auto for a key-value iteration is idiomatic, as it's used for all std::map<string, string> iteration. | |
5952 | renamed to processNotesHelper. | |
7311 | (renamed to DynamicEntryKV, as elsewhere) |
@fmayer / @jhenderson / @MaskRay , would you folks mind taking a second pass? thanks.
llvm/test/tools/llvm-readobj/ELF/AArch64/memtag-missing.test | ||
---|---|---|
1 ↗ | (On Diff #497772) | This file can be folded into memtag.test by using yaml2obj --docnum. Being a separate test, CHECK-NOT: Memtag Android Note below can easily go stale without being noticed. |
5 ↗ | (On Diff #497772) | I think you can just enumerate all lines since the output is very short. Add CHECK-NOT: {{.}} in the end to assert that there is no additional output. |
6 ↗ | (On Diff #497772) | |
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
301 | ArrayRef is usually passed by value | |
586 | ArrayRef is usually passed by value | |
693 | ArrayRef is usually passed by value | |
5899 | These need a e_machine == EM_AARCH64 check. These values are in the processor-specific dynamic tag range. | |
5904 | Drop .c_str(). getDynamicTagAsString returns is a std::string. |
llvm/docs/CommandGuide/llvm-readelf.rst | ||
---|---|---|
122 | various dynamic entries => various memtag-specific dynamic entries ? |
You need to update llvm-readobj.rst as well with the new option (we have separate documents for the two of them because there are several options that aren't shared).
llvm/test/tools/llvm-readobj/ELF/AArch64/memtag-missing.test | ||
---|---|---|
13 ↗ | (On Diff #497018) | Is ordering important here? CHECK-NOT will just show that this pattern won't appear since the last positive match, so if the unexpected output appears before the "Memtag Dynamic Entries" bit, it'll not catch it. If ordering isn't relevant here, you may wish to use FileCheck's "--implicit-check-not=Memtag Android Note". |
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
2274 | If memory serves me correctly, Twine has a constructor that effectively can do the std::to_string, so you should use that. Same goes for below. | |
5241 | I guess in my mind, it wasn't obvious that this was a key-value situation, but the renaming helps, thanks. | |
5891 | Nit: has this been clang-formatted? If so, I'm marginally surprised that the format is []() {} not [](){}. |
I noticed that there were a couple of llvm-readobj test failures in the pre-merge checks. Are either of them related to your change possibly?
Address MaskRay and jhenderson's comments.
Let's see how the pre-merge bots go with this instance. Honestly, I've had so many times where the pre-merge bots show garbage results that I don't trust them any more :).
various dynamic entries => various memtag-specific dynamic entries ?