On 04/12/2014 12:30 AM, Mark Wielaard wrote:
+const char *
+dwelf_elf_gnu_debuglink (Elf *elf, GElf_Word *crc)
+{
+ size_t shstrndx;
+ if (elf_getshdrstrndx (elf, &shstrndx) < 0)
+ return NULL;
+
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ return NULL;
+
+ const char *name = elf_strptr (elf, shstrndx, shdr->sh_name);
+ if (name == NULL)
+ return NULL;
+
+ if (!strcmp (name, ".gnu_debuglink"))
+ break;
+ }
+
+ if (scn == NULL)
+ return NULL;
I think this should be part of a separate helper function because I need
pretty much the same loop for implementing debugaltlink access.
Perhaps dwelf_elf_gnu_debuglink should extract the data from an Elf_Scn
pointer, relying on the caller to locate the section? On the other
hand, that would make this convenience function more difficult to use.
--
Florian Weimer / Red Hat Product Security Team