/* Section header. */
typedef struct
{
Elf32_Word sh_name; /* Section name (string tbl index) */
Elf32_Word sh_type; /* Section type */
Elf32_Word sh_flags; /* Section flags */
Elf32_Addr sh_addr; /* Section virtual addr at execution */
Elf32_Off sh_offset; /* Section file offset */
Elf32_Word sh_size; /* Section size in bytes */
Elf32_Word sh_link; /* Link to another section */
Elf32_Word sh_info; /* Additional section information */
Elf32_Word sh_addralign; /* Section alignment */
Elf32_Word sh_entsize; /* Entry size if section holds table */
} Elf32_Shdr;
.debug_aranges
.debug_info
.debug_abbrev
.debug_line
.debug_str
[beyes@beyes elf]$ ./testefl.debug
31
hello 2012
[beyes@beyes elf]$ strip --strip-debug testefl.debug -o testefl.debugstrip
[beyes@beyes elf]$ ./testefl.debugstrip
31
hello 2012
Reading symbols from /home/beyes/c/elf/testefl.debugstrip...(no debugging symbols found)...done.
(gdb) l
No symbol table is loaded. Use the "file" command.
/* Symbol table entry. */
typedef struct
{
Elf32_Word st_name; /* Symbol name (string tbl index) */
Elf32_Addr st_value; /* Symbol value */
Elf32_Word st_size; /* Symbol size */
unsigned char st_info; /* Symbol type and binding */
unsigned char st_other; /* Symbol visibility */
Elf32_Section st_shndx; /* Section index */
} Elf32_Sym;
[beyes@beyes elf]$ readelf -s testefl.o
Symbol table '.symtab' contains 16 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FILE LOCAL DEFAULT ABS testefl.c
2: 00000000 0 SECTION LOCAL DEFAULT 1
3: 00000000 0 SECTION LOCAL DEFAULT 3
4: 00000000 0 SECTION LOCAL DEFAULT 5
5: 00000000 0 SECTION LOCAL DEFAULT 6
6: 00000000 0 SECTION LOCAL DEFAULT 8
7: 00000000 0 SECTION LOCAL DEFAULT 9
8: 00000000 0 SECTION LOCAL DEFAULT 7
9: 00000000 4 OBJECT GLOBAL DEFAULT 3 strp
10: 00000004 4 OBJECT GLOBAL DEFAULT COM c
11: 00000000 13 FUNC GLOBAL DEFAULT 1 plusfunc
12: 0000000d 19 FUNC GLOBAL DEFAULT 1 printstring
13: 00000000 0 NOTYPE GLOBAL DEFAULT UND puts
14: 00000020 93 FUNC GLOBAL DEFAULT 1 main
15: 00000000 0 NOTYPE GLOBAL DEFAULT UND printf
/* 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)
#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |