@@ -71,6 +71,11 @@ static inline void elfFile_lineProgramCallback(struct dwarf_lineInfo info, void*
7171 vector_push_back (& self -> lineInfos , info );
7272}
7373
74+ /**
75+ * Generates an implementation for parsing the string table section.
76+ *
77+ * @param bits the amount of bits the implementation shall handle
78+ */
7479#define elfFile_loadSectionStrtab (bits ) \
7580static inline char* elfFile_loadSectionStrtab##bits(Elf##bits##_Ehdr* header, bool littleEndian) { \
7681 uint16_t index = ELF_TO_HOST(16, header->e_shstrndx, littleEndian); \
@@ -93,6 +98,11 @@ static inline char* elfFile_loadSectionStrtab##bits(Elf##bits##_Ehdr* header, bo
9398elfFile_loadSectionStrtab (32 )
9499elfFile_loadSectionStrtab (64 )
95100
101+ /**
102+ * Generates an implementation for parsing the symbol table.
103+ *
104+ * @param bits the amount of bits the implementation shall handle
105+ */
96106#define elfFile_parseSymtab (bits ) \
97107static inline bool elfFile_parseSymtab##bits(struct elfFile* self, \
98108 Elf##bits##_Shdr* symtab, \
@@ -119,6 +129,11 @@ static inline bool elfFile_parseSymtab##bits(struct elfFile* self,
119129elfFile_parseSymtab (32 )
120130elfFile_parseSymtab (64 )
121131
132+ /**
133+ * Generates an implementation for converting an ELF section to an LCS one.
134+ *
135+ * @param bits the amount of bits the implementation shall handle
136+ */
122137#define elfFile_sectionToLCSSection (bits ) \
123138static inline struct lcs_section elfFile_sectionToLCSSection##bits(void* buffer, \
124139 Elf##bits##_Shdr* section, \
@@ -132,6 +147,11 @@ static inline struct lcs_section elfFile_sectionToLCSSection##bits(void*
132147elfFile_sectionToLCSSection (32 )
133148elfFile_sectionToLCSSection (64 )
134149
150+ /**
151+ * Generates an implementation for loading the number of section headers.
152+ *
153+ * @param bits the amount of bits the implementation shall handle
154+ */
135155#define elfFile_loadShnum (bits ) \
136156static inline uint64_t elfFile_loadShnum##bits(Elf##bits##_Ehdr* buffer, bool littleEndian) { \
137157 uint64_t shnum = ELF_TO_HOST(16, buffer->e_shnum, littleEndian); \
@@ -150,6 +170,11 @@ static inline uint64_t elfFile_loadShnum##bits(Elf##bits##_Ehdr* buffer, bool li
150170elfFile_loadShnum (32 )
151171elfFile_loadShnum (64 )
152172
173+ /**
174+ * Generates an implementation for parsing an ELF file.
175+ *
176+ * @param bits the amount of bits the implementation shall handle
177+ */
153178#define elfFile_parseFileImpl (bits ) \
154179static inline bool elfFile_parseFile##bits (struct elfFile* self, Elf##bits##_Ehdr* buffer, bool littleEndian) { \
155180 if (ELF_TO_HOST(bits, buffer->e_shoff, littleEndian) == 0) return false; \
@@ -261,7 +286,8 @@ static inline bool elfFile_parseFile(struct elfFile* self, void* buffer) {
261286 *
262287 * @param lhs the left-hand side value
263288 * @param rhs the right-hand side value
264- * @return `0` if the two functions compare equal or a value smaller or greater than `0` according to the sorting order
289+ * @return @c 0 if the two functions compare equal or a value smaller or
290+ * greater than @c 0 according to the sorting order
265291 */
266292static inline int elfFile_functionCompare (const void * lhs , const void * rhs ) {
267293 const struct function * a = lhs ,
@@ -279,7 +305,8 @@ static inline int elfFile_functionCompare(const void* lhs, const void* rhs) {
279305 *
280306 * @param lhs the left-hand side value
281307 * @param rhs the right-hand side value
282- * @return `0` if the two infos compare equal or a value smaller or greater than `0` according to the sorting order
308+ * @return @c 0 if the two infos compare equal or a value smaller or greater
309+ * than @c 0 according to the sorting order
283310 */
284311static inline int elfFile_lineInfoCompare (const void * lhs , const void * rhs ) {
285312 const struct dwarf_lineInfo * a = lhs ,
@@ -312,8 +339,8 @@ bool elfFile_parse(struct elfFile* self) {
312339}
313340
314341/**
315- * Deducts the debugging information available for the given address in the given
316- * ELF file abstraction object.
342+ * Deducts the debugging information available for the given address in the
343+ * given ELF file abstraction object.
317344 *
318345 * @param self the ELF file abstraction object to be searched
319346 * @param address the address to be translated
@@ -323,7 +350,7 @@ static inline optional_debugInfo_t elfFile_getDebugInfo(struct elfFile* self, vo
323350 optional_debugInfo_t toReturn = { .has_value = false };
324351
325352 const uint64_t translated = (uintptr_t ) address - self -> _ .relocationOffset ;
326- struct function tmp = (struct function ) { .startAddress = translated };
353+ const struct function tmp = (struct function ) { .startAddress = translated };
327354 const struct function * closest = lower_bound (& tmp ,
328355 self -> functions .content ,
329356 self -> functions .count ,
@@ -348,8 +375,8 @@ static inline optional_debugInfo_t elfFile_getDebugInfo(struct elfFile* self, vo
348375 .sourceFileInfo = { .has_value = false }
349376 }
350377 };
351-
352- struct dwarf_lineInfo tmpInfo = (struct dwarf_lineInfo ) { .address = translated };
378+
379+ const struct dwarf_lineInfo tmpInfo = (struct dwarf_lineInfo ) { .address = translated };
353380 const struct dwarf_lineInfo * closestInfo = upper_bound (& tmpInfo ,
354381 self -> lineInfos .content ,
355382 self -> lineInfos .count ,
0 commit comments