From de623f267918a316e1c8c9fa63ccee67922470cf Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Fri, 1 Jan 2010 23:53:30 +0300 Subject: [PATCH] elf.h: Add ELFXX_ST_MKBIND and move ELFXX_ST_ helpers The profit of ELFXX_ST_MKBIND helper is that we will use it for SYM_GLOBAL explicitly pointing out from where this magic 0x10 came from. Signed-off-by: Cyrill Gorcunov --- output/elf.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/output/elf.h b/output/elf.h index 4ee8635e..ebdbfe6c 100644 --- a/output/elf.h +++ b/output/elf.h @@ -251,6 +251,17 @@ #define STV_HIDDEN 2 /* Sym unavailable in other modules */ #define STV_PROTECTED 3 /* Not preemptible, not exported */ +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field */ +#define ELF32_ST_BIND(i) ((i) >> 4) +#define ELF32_ST_MKBIND(i) ((i) << 4) /* just a helper */ +#define ELF32_ST_TYPE(i) ((i) & 0xf) +#define ELF32_ST_INFO(b, i) (ELF_ST_MKBIND(b) + ELF_ST_TYPE(i)) + +#define ELF64_ST_BIND(i) ELF32_ST_BIND(i) +#define ELF64_ST_MKBIND(i) ELF32_ST_MKBIND(i) +#define ELF64_ST_TYPE(i) ELF32_ST_TYPE(i) +#define ELF64_ST_INFO(b, i) ELF32_ST_INFO(b, i) + /* * ELF standard typedefs (yet more proof that was way overdue) */ @@ -520,12 +531,4 @@ typedef struct elf64_note { Elf64_Word n_type; /* Content type */ } Elf64_Nhdr; -/* How to extract and insert information held in the st_info field. */ -#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) -#define ELF32_ST_TYPE(val) ((val) & 0xf) - -/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ -#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) -#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) - #endif /* OUTPUT_ELF_H */