[PATCH] D24706: [ELF] - Partial support of --gdb-index command line option (Part 1).
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 20 20:57:02 PDT 2016
ruiu added inline comments.
================
Comment at: ELF/OutputSections.cpp:65
@@ +64,3 @@
+ if (!DebugInfoSec) {
+ error(".debug_info is required for building .gdb_index");
+ return false;
----------------
Please include a file name in the error message.
================
Comment at: ELF/OutputSections.cpp:71
@@ +70,3 @@
+ for (InputSection<ELFT> *I : IS)
+ DwarfInfoReader<ELFT>(*this, I).addToGdbIndex();
+ return true;
----------------
Looks like this can be written in a more functional programming style like this.
CompilationUnits = readDwarf(I);
where readDwarf is a new function that returns a new vector.
Currently, it is not clear what DwarfInfoReader would do to its arguments.
================
Comment at: ELF/OutputSections.cpp:86-110
@@ +85,27 @@
+template <class ELFT> void GdbIndexSection<ELFT>::writeTo(uint8_t *Buf) {
+ // Write version.
+ write32le(Buf, 7);
+ Buf += 4;
+
+ write32le(Buf, CuListOffset);
+ Buf += 4;
+
+ // Offset of the types CU list.
+ write32le(Buf, CuTypesOffset);
+ Buf += 4;
+
+ // Offset of the address area, the same as offset of the types CU list,
+ // as we dont support types CU lists, so it is empty.
+ write32le(Buf, CuTypesOffset);
+ Buf += 4;
+
+ // Offset of the symbol table, the same as offset of the types CU list,
+ // we do not fill it yet.
+ write32le(Buf, CuTypesOffset);
+ Buf += 4;
+
+ // Offset of the constant pool, the same as offset of the types CU list,
+ // we do not fill it yet.
+ write32le(Buf, CuTypesOffset);
+ Buf += 4;
+
----------------
I'd save lines here.
write32le(Buf, 7); // Version
write32le(Buf + 4, CutListOffset); // [what is this?]
write32le(Buf + 8, CutListOffset); // Offset of the address area
write32le(Buf + 12, CutListOffset); // ...
...
Buf += 24;
Or, maybe we should define a struct for the header in libObject/libSupport.
https://reviews.llvm.org/D24706
More information about the llvm-commits
mailing list