Turn elfu_gPhdrContainsScn into a macro
[centaur.git] / src / printing / segments.c
index 6d8cac7223c6f003d73e845db781dc4520ea242a..c7b5cb2555190749781bb1d542a88bc7e6fcee3c 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdio.h>
 
-#include <libelf.h>
-#include <gelf.h>
+#include <libelf/libelf.h>
+#include <libelf/gelf.h>
 
 #include <libelfu/libelfu.h>
 
@@ -26,11 +26,15 @@ void printSectionsInSegment(Elf *e, GElf_Phdr *phdr)
   scn = elf_getscn(e, 0);
 
   while (scn) {
-    ELFU_BOOL isInSeg;
+    GElf_Shdr shdr;
 
-    isInSeg = elfu_segmentContainsSection(phdr, scn);
-    if (isInSeg == ELFU_TRUE) {
-      printf("       %10u %s\n", elf_ndxscn(scn), elfu_sectionName(e, scn));
+    if (gelf_getshdr(scn, &shdr) != &shdr) {
+      fprintf(stderr, "gelf_getshdr() failed: %s\n", elf_errmsg(-1));
+      continue;
+    }
+
+    if (PHDR_CONTAINS_SCN_IN_MEMORY(phdr, &shdr)) {
+      printf("       %10u %s\n", elf_ndxscn(scn), elfu_eScnName(e, scn));
     }
 
     scn = elf_nextscn(e, scn);