#include #include static void symtest(void) { printf("test\n"); } int main(int argc, char *argv[]) { void *func; func = dlfunc(NULL, "symtest"); printf("%s:%u: FUNC=%p\n", __func__, __LINE__, func); symtest(); return (0); } gcc -Wall -Wl,-E test144.c -o test144 ELF Header: Magic: 7f 45 4c 46 02 01 01 09 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - FreeBSD ABI Version: 0 Type: EXEC (Executable file) Machine: Advanced Micro Devices X86-64 Version: 0x1 Entry point address: 0x400610 Start of program headers: 64 (bytes into file) Start of section headers: 3376 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 8 Size of section headers: 64 (bytes) Number of section headers: 27 Section header string table index: 24 Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .interp PROGBITS 0000000000400200 00000200 0000000000000015 0000000000000000 A 0 0 1 [ 2] .note.ABI-tag NOTE 0000000000400218 00000218 0000000000000018 0000000000000000 A 0 0 4 [ 3] .hash HASH 0000000000400230 00000230 0000000000000058 0000000000000004 A 4 0 8 [ 4] .dynsym DYNSYM 0000000000400288 00000288 0000000000000198 0000000000000018 A 5 1 8 [ 5] .dynstr STRTAB 0000000000400420 00000420 0000000000000088 0000000000000000 A 0 0 1 [ 6] .gnu.version VERSYM 00000000004004a8 000004a8 0000000000000022 0000000000000002 A 4 0 2 [ 7] .gnu.version_r VERNEED 00000000004004d0 000004d0 0000000000000020 0000000000000000 A 5 1 8 [ 8] .rela.plt RELA 00000000004004f0 000004f0 0000000000000090 0000000000000018 A 4 10 8 [ 9] .init PROGBITS 0000000000400580 00000580 0000000000000013 0000000000000000 AX 0 0 4 [10] .plt PROGBITS 0000000000400594 00000594 0000000000000070 0000000000000010 AX 0 0 4 [11] .text PROGBITS 0000000000400610 00000610 00000000000001a4 0000000000000000 AX 0 0 16 [12] .fini PROGBITS 00000000004007b4 000007b4 000000000000000e 0000000000000000 AX 0 0 4 [13] .rodata PROGBITS 00000000004007c2 000007c2 0000000000000023 0000000000000000 A 0 0 1 [14] .eh_frame_hdr PROGBITS 00000000004007e8 000007e8 0000000000000024 0000000000000000 A 0 0 4 [15] .eh_frame PROGBITS 0000000000400810 00000810 0000000000000084 0000000000000000 A 0 0 8 [16] .ctors PROGBITS 0000000000600898 00000898 0000000000000010 0000000000000000 WA 0 0 8 [17] .dtors PROGBITS 00000000006008a8 000008a8 0000000000000010 0000000000000000 WA 0 0 8 [18] .jcr PROGBITS 00000000006008b8 000008b8 0000000000000008 0000000000000000 WA 0 0 8 [19] .dynamic DYNAMIC 00000000006008c0 000008c0 0000000000000160 0000000000000010 WA 5 0 8 [20] .got.plt PROGBITS 0000000000600a20 00000a20 0000000000000048 0000000000000008 WA 0 0 8 [21] .data PROGBITS 0000000000600a68 00000a68 0000000000000018 0000000000000000 WA 0 0 8 [22] .bss NOBITS 0000000000600a80 00000a80 0000000000000010 0000000000000000 WA 0 0 8 [23] .comment PROGBITS 0000000000000000 00000a80 00000000000001d3 0000000000000000 0 0 1 [24] .shstrtab STRTAB 0000000000000000 00000c53 00000000000000d8 0000000000000000 0 0 1 [25] .symtab SYMTAB 0000000000000000 000013f0 00000000000005d0 0000000000000018 26 46 8 [26] .strtab STRTAB 0000000000000000 000019c0 00000000000001cd 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) There are no section groups in this file. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040 0x00000000000001c0 0x00000000000001c0 R E 8 INTERP 0x0000000000000200 0x0000000000400200 0x0000000000400200 0x0000000000000015 0x0000000000000015 R 1 [Requesting program interpreter: /libexec/ld-elf.so.1] LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x0000000000000894 0x0000000000000894 R E 200000 LOAD 0x0000000000000898 0x0000000000600898 0x0000000000600898 0x00000000000001e8 0x00000000000001f8 RW 200000 DYNAMIC 0x00000000000008c0 0x00000000006008c0 0x00000000006008c0 0x0000000000000160 0x0000000000000160 RW 8 NOTE 0x0000000000000218 0x0000000000400218 0x0000000000400218 0x0000000000000018 0x0000000000000018 R 4 GNU_EH_FRAME 0x00000000000007e8 0x00000000004007e8 0x00000000004007e8 0x0000000000000024 0x0000000000000024 R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 8 Section to Segment mapping: Segment Sections... 00 01 .interp 02 .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame 03 .ctors .dtors .jcr .dynamic .got.plt .data .bss 04 .dynamic 05 .note.ABI-tag 06 .eh_frame_hdr 07 Dynamic section at offset 0x8c0 contains 17 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libc.so.7] 0x000000000000000c (INIT) 0x400580 0x000000000000000d (FINI) 0x4007b4 0x0000000000000004 (HASH) 0x400230 0x0000000000000005 (STRTAB) 0x400420 0x0000000000000006 (SYMTAB) 0x400288 0x000000000000000a (STRSZ) 136 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000015 (DEBUG) 0x0 0x0000000000000003 (PLTGOT) 0x600a20 0x0000000000000002 (PLTRELSZ) 144 (bytes) 0x0000000000000014 (PLTREL) RELA 0x0000000000000017 (JMPREL) 0x4004f0 0x000000006ffffffe (VERNEED) 0x4004d0 0x000000006fffffff (VERNEEDNUM) 1 0x000000006ffffff0 (VERSYM) 0x4004a8 0x0000000000000000 (NULL) 0x0 Relocation section '.rela.plt' at offset 0x4f0 contains 6 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000600a38 000500000007 R_X86_64_JUMP_SLO 0000000000000000 printf + 0 000000600a40 000600000007 R_X86_64_JUMP_SLO 0000000000000000 atexit + 0 000000600a48 000700000007 R_X86_64_JUMP_SLO 0000000000000000 _init_tls + 0 000000600a50 000a00000007 R_X86_64_JUMP_SLO 0000000000000000 dlfunc + 0 000000600a58 000c00000007 R_X86_64_JUMP_SLO 0000000000000000 exit + 0 000000600a60 001000000007 R_X86_64_JUMP_SLO 0000000000000000 puts + 0 There are no unwind sections in this file. Symbol table '.dynsym' contains 17 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000400610 156 FUNC GLOBAL DEFAULT 11 _start 2: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses 3: 0000000000600a68 8 OBJECT GLOBAL DEFAULT 21 __progname 4: 00000000004007b4 0 FUNC GLOBAL DEFAULT 12 _fini 5: 0000000000000000 162 FUNC GLOBAL DEFAULT UND printf@FBSD_1.0 (2) 6: 0000000000000000 47 FUNC GLOBAL DEFAULT UND atexit@FBSD_1.0 (2) 7: 0000000000000000 2 FUNC GLOBAL DEFAULT UND _init_tls@FBSD_1.0 (2) 8: 0000000000600a80 0 NOTYPE GLOBAL DEFAULT ABS __bss_start 9: 0000000000600a88 8 OBJECT GLOBAL DEFAULT 22 environ 10: 0000000000000000 25 FUNC GLOBAL DEFAULT UND dlfunc@FBSD_1.0 (2) 11: 0000000000600a90 0 NOTYPE GLOBAL DEFAULT ABS _end 12: 0000000000000000 47 FUNC GLOBAL DEFAULT UND exit@FBSD_1.0 (2) 13: 0000000000600a80 0 NOTYPE GLOBAL DEFAULT ABS _edata 14: 0000000000400730 75 FUNC GLOBAL DEFAULT 11 main 15: 0000000000400580 0 FUNC GLOBAL DEFAULT 9 _init 16: 0000000000000000 210 FUNC GLOBAL DEFAULT UND puts@FBSD_1.0 (2) Symbol table '.symtab' contains 62 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000400200 0 SECTION LOCAL DEFAULT 1 2: 0000000000400218 0 SECTION LOCAL DEFAULT 2 3: 0000000000400230 0 SECTION LOCAL DEFAULT 3 4: 0000000000400288 0 SECTION LOCAL DEFAULT 4 5: 0000000000400420 0 SECTION LOCAL DEFAULT 5 6: 00000000004004a8 0 SECTION LOCAL DEFAULT 6 7: 00000000004004d0 0 SECTION LOCAL DEFAULT 7 8: 00000000004004f0 0 SECTION LOCAL DEFAULT 8 9: 0000000000400580 0 SECTION LOCAL DEFAULT 9 10: 0000000000400594 0 SECTION LOCAL DEFAULT 10 11: 0000000000400610 0 SECTION LOCAL DEFAULT 11 12: 00000000004007b4 0 SECTION LOCAL DEFAULT 12 13: 00000000004007c2 0 SECTION LOCAL DEFAULT 13 14: 00000000004007e8 0 SECTION LOCAL DEFAULT 14 15: 0000000000400810 0 SECTION LOCAL DEFAULT 15 16: 0000000000600898 0 SECTION LOCAL DEFAULT 16 17: 00000000006008a8 0 SECTION LOCAL DEFAULT 17 18: 00000000006008b8 0 SECTION LOCAL DEFAULT 18 19: 00000000006008c0 0 SECTION LOCAL DEFAULT 19 20: 0000000000600a20 0 SECTION LOCAL DEFAULT 20 21: 0000000000600a68 0 SECTION LOCAL DEFAULT 21 22: 0000000000600a80 0 SECTION LOCAL DEFAULT 22 23: 0000000000000000 0 SECTION LOCAL DEFAULT 23 24: 0000000000000000 0 FILE LOCAL DEFAULT ABS crt1.c 25: 0000000000400218 24 OBJECT LOCAL DEFAULT 2 abitag 26: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c 27: 0000000000600898 0 OBJECT LOCAL DEFAULT 16 __CTOR_LIST__ 28: 00000000006008a8 0 OBJECT LOCAL DEFAULT 17 __DTOR_LIST__ 29: 00000000006008b8 0 OBJECT LOCAL DEFAULT 18 __JCR_LIST__ 30: 00000000004006b0 0 FUNC LOCAL DEFAULT 11 __do_global_dtors_aux 31: 0000000000600a80 1 OBJECT LOCAL DEFAULT 22 completed.5129 32: 0000000000600a78 0 OBJECT LOCAL DEFAULT 21 p.5127 33: 00000000004006f0 0 FUNC LOCAL DEFAULT 11 frame_dummy 34: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c 35: 00000000006008a0 0 OBJECT LOCAL DEFAULT 16 __CTOR_END__ 36: 00000000006008b0 0 OBJECT LOCAL DEFAULT 17 __DTOR_END__ 37: 0000000000400890 0 OBJECT LOCAL DEFAULT 15 __FRAME_END__ 38: 00000000006008b8 0 OBJECT LOCAL DEFAULT 18 __JCR_END__ 39: 0000000000400780 0 FUNC LOCAL DEFAULT 11 __do_global_ctors_aux 40: 0000000000000000 0 FILE LOCAL DEFAULT ABS test144.c 41: 0000000000400720 16 FUNC LOCAL DEFAULT 11 symtest 42: 00000000004007c8 5 OBJECT LOCAL DEFAULT 13 __func__.2362 43: 0000000000600a20 0 OBJECT LOCAL HIDDEN 20 _GLOBAL_OFFSET_TABLE_ 44: 0000000000600a70 0 OBJECT LOCAL HIDDEN 21 __dso_handle 45: 00000000006008c0 0 OBJECT LOCAL HIDDEN 19 _DYNAMIC 46: 0000000000400610 156 FUNC GLOBAL DEFAULT 11 _start 47: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses 48: 0000000000600a68 8 OBJECT GLOBAL DEFAULT 21 __progname 49: 00000000004007b4 0 FUNC GLOBAL DEFAULT 12 _fini 50: 0000000000000000 162 FUNC GLOBAL DEFAULT UND printf@@FBSD_1.0 51: 0000000000000000 47 FUNC GLOBAL DEFAULT UND atexit@@FBSD_1.0 52: 0000000000000000 2 FUNC GLOBAL DEFAULT UND _init_tls@@FBSD_1.0 53: 0000000000600a80 0 NOTYPE GLOBAL DEFAULT ABS __bss_start 54: 0000000000600a88 8 OBJECT GLOBAL DEFAULT 22 environ 55: 0000000000000000 25 FUNC GLOBAL DEFAULT UND dlfunc@@FBSD_1.0 56: 0000000000600a90 0 NOTYPE GLOBAL DEFAULT ABS _end 57: 0000000000000000 47 FUNC GLOBAL DEFAULT UND exit@@FBSD_1.0 58: 0000000000600a80 0 NOTYPE GLOBAL DEFAULT ABS _edata 59: 0000000000400730 75 FUNC GLOBAL DEFAULT 11 main 60: 0000000000400580 0 FUNC GLOBAL DEFAULT 9 _init 61: 0000000000000000 210 FUNC GLOBAL DEFAULT UND puts@@FBSD_1.0 Histogram for bucket list length (total of 3 buckets): Length Number % of total Coverage 0 0 ( 0.0%) 1 0 ( 0.0%) 0.0% 2 0 ( 0.0%) 0.0% 3 0 ( 0.0%) 0.0% 4 1 ( 33.3%) 25.0% 5 1 ( 33.3%) 56.2% 6 0 ( 0.0%) 56.2% 7 1 ( 33.3%) 100.0% Version symbols section '.gnu.version' contains 17 entries: Addr: 00000000004004a8 Offset: 0x0004a8 Link: 4 (.dynsym) 000: 0 (*local*) 1 (*global*) 0 (*local*) 1 (*global*) 004: 1 (*global*) 2 (FBSD_1.0) 2 (FBSD_1.0) 2 (FBSD_1.0) 008: 1 (*global*) 1 (*global*) 2 (FBSD_1.0) 1 (*global*) 00c: 2 (FBSD_1.0) 1 (*global*) 1 (*global*) 1 (*global*) 010: 2 (FBSD_1.0) Version needs section '.gnu.version_r' contains 1 entries: Addr: 0x00000000004004d0 Offset: 0x0004d0 Link to section: 5 (.dynstr) 000000: Version: 1 File: libc.so.7 Cnt: 1 0x0010: Name: FBSD_1.0 Flags: none Version: 2 Notes at offset 0x00000218 with length 0x00000018: Owner Data size Description FreeBSD 0x00000004 NT_VERSION (version)