diff options
author | Matt Turner <mattst88@gmail.com> | 2016-12-14 16:04:26 -0800 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2016-12-14 16:19:48 -0800 |
commit | 838ebbcf92352217ea7ed16e0894ea585a357f88 (patch) | |
tree | f4a4a1217c84210da3f785e0836d23ab10e5896e /build-id.h | |
parent | 9728a8bdc1d882acf534df6a86dbb435146a5ca8 (diff) |
Use dl_iterate_phdr() instead of a linker script.
According to Mike Frysinger [1] it is not reliable to read ELF sections
at runtime, which the previous method involving the linker script was
doing.
Instead, use dl_iterate_phdr() to find the build id.
[1] https://sourceware.org/ml/binutils/2016-12/msg00207.html
Diffstat (limited to 'build-id.h')
-rw-r--r-- | build-id.h | 23 |
1 files changed, 8 insertions, 15 deletions
@@ -22,24 +22,17 @@ * IN THE SOFTWARE. */ -#include <elf.h> -#include <stdio.h> -#include <string.h> +#define _GNU_SOURCE +#include <link.h> +#include <stdint.h> -#if __x86_64__ -# define ElfW(type) Elf64_##type -#else -# define ElfW(type) Elf32_##type -#endif +struct note; -void -so_print(void); - -const ElfW(Nhdr) * -build_id_find_nhdr(void); +const struct note * +build_id_find_nhdr(const char *name); ElfW(Word) -build_id_length(const ElfW(Nhdr) *nhdr); +build_id_length(const struct note *note); void -build_id_read(const ElfW(Nhdr) *nhdr, unsigned char *build_id); +build_id_read(const struct note *note, unsigned char *build_id); |