This is motivated by https://reviews.llvm.org/D32488 where I am trying to
add printing of the section type for incompatible sections to LLD error
messages. This patch allows us to use the same code in llvm-readobj and
LLD instead of duplicating the function inside LLD.
Details
- Reviewers
ruiu grimar • rafael davide - Commits
- rL301921: Add llvm::object::getELFSectionTypeName().
Diff Detail
- Build Status
Buildable 6023 Build 6023: arc lint + arc unit
Event Timeline
lib/Object/ELF.cpp | ||
---|---|---|
153 | I would use some macro here. Like in original code and #define ELF_RELOC(name, value) \ case ELF::name: \ return #name; \ It should do code shorter and be less errorprone. |
lib/Object/ELF.cpp | ||
---|---|---|
153 | Yes, since this file already uses a macro, it is better to use a macro too for consistency in this case. |
lib/Object/ELF.cpp | ||
---|---|---|
240 | It is probably more convenient to return 0x<hex> from this function for unknown types. |
lib/Object/ELF.cpp | ||
---|---|---|
240 | This would mean that llvm-readobj would output Type: 0x1234567 (0x1234567) as it always appends the hex value. Also we can't return a const char* then and would need to return std::string. As the name of the function is getELFSectionTypeName() I think it is fine to return "" for unknown names because there is no known name for that section type. |
lib/Object/ELF.cpp | ||
---|---|---|
240 | Then how about returning "Unknown"? That's what getELFRelocationTypeName defined above is doing, so it is good from the perspective of consistency too. |
Fix alignment.