From 9a309e895bb88a083440228bd32c5766d540e1a7 Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 5 Jun 2015 22:28:12 -0400 Subject: weak symbols using mingw toolchain --- weak/a.c | 11 ++++++++++ weak/a.o | Bin 0 -> 848 bytes weak/a.o.dis | 34 +++++++++++++++++++++++++++++ weak/a_and_b.log | 2 ++ weak/aonly.dll.dis | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ weak/b.c | 7 ++++++ weak/b.o | Bin 0 -> 700 bytes weak/b.o.dis | 13 ++++++++++++ 8 files changed, 128 insertions(+) create mode 100644 weak/a.c create mode 100644 weak/a.o create mode 100644 weak/a.o.dis create mode 100644 weak/a_and_b.log create mode 100644 weak/aonly.dll.dis create mode 100644 weak/b.c create mode 100644 weak/b.o create mode 100644 weak/b.o.dis diff --git a/weak/a.c b/weak/a.c new file mode 100644 index 0000000..49f7d57 --- /dev/null +++ b/weak/a.c @@ -0,0 +1,11 @@ +int __sym(int x) +{ + return x+1; +} + +extern int sym(int x) __attribute__((weak,alias("__sym"))); + +int same(int x) +{ + return sym(x)*3; +} diff --git a/weak/a.o b/weak/a.o new file mode 100644 index 0000000..98fded8 Binary files /dev/null and b/weak/a.o differ diff --git a/weak/a.o.dis b/weak/a.o.dis new file mode 100644 index 0000000..f93146b --- /dev/null +++ b/weak/a.o.dis @@ -0,0 +1,34 @@ + +a.o: Dateiformat pe-x86-64 + + +Disassembly of section .text: + +0000000000000000 <__sym>: + 0: 8d 41 01 lea 0x1(%rcx),%eax + 3: c3 retq + 4: 66 66 66 2e 0f 1f 84 data32 data32 nopw %cs:0x0(%rax,%rax,1) + b: 00 00 00 00 00 + +0000000000000010 : + 10: 48 83 ec 28 sub $0x28,%rsp + 14: e8 00 00 00 00 callq 19 + 15: R_X86_64_PC32 sym + 19: 8d 04 40 lea (%rax,%rax,2),%eax + 1c: 48 83 c4 28 add $0x28,%rsp + 20: c3 retq + 21: 90 nop + 22: 90 nop + 23: 90 nop + 24: 90 nop + 25: 90 nop + 26: 90 nop + 27: 90 nop + 28: 90 nop + 29: 90 nop + 2a: 90 nop + 2b: 90 nop + 2c: 90 nop + 2d: 90 nop + 2e: 90 nop + 2f: 90 nop diff --git a/weak/a_and_b.log b/weak/a_and_b.log new file mode 100644 index 0000000..e989602 --- /dev/null +++ b/weak/a_and_b.log @@ -0,0 +1,2 @@ +a.o:a.c:(.text+0x15): undefined reference to `sym' +b.o:b.c:(.text+0x5): undefined reference to `sym' diff --git a/weak/aonly.dll.dis b/weak/aonly.dll.dis new file mode 100644 index 0000000..3f23601 --- /dev/null +++ b/weak/aonly.dll.dis @@ -0,0 +1,61 @@ + +aonly.dll: file format pei-x86-64 + + +Disassembly of section .text: + +0000000010001000 <__sym>: + 10001000: 8d 41 01 lea 0x1(%rcx),%eax + 10001003: c3 retq + 10001004: 66 66 66 2e 0f 1f 84 data32 data32 nopw %cs:0x0(%rax,%rax,1) + 1000100b: 00 00 00 00 00 + +0000000010001010 : + 10001010: 48 83 ec 28 sub $0x28,%rsp + 10001014: e8 e7 ff ff ff callq 10001000 <__sym> + 10001019: 8d 04 40 lea (%rax,%rax,2),%eax + 1000101c: 48 83 c4 28 add $0x28,%rsp + 10001020: c3 retq + 10001021: 90 nop + 10001022: 90 nop + 10001023: 90 nop + 10001024: 90 nop + 10001025: 90 nop + 10001026: 90 nop + 10001027: 90 nop + 10001028: 90 nop + 10001029: 90 nop + 1000102a: 90 nop + 1000102b: 90 nop + 1000102c: 90 nop + 1000102d: 90 nop + 1000102e: 90 nop + 1000102f: 90 nop + +0000000010001030 <__CTOR_LIST__>: + 10001030: ff (bad) + 10001031: ff (bad) + 10001032: ff (bad) + 10001033: ff (bad) + 10001034: ff (bad) + 10001035: ff (bad) + 10001036: ff (bad) + 10001037: ff 00 incl (%rax) + 10001039: 00 00 add %al,(%rax) + 1000103b: 00 00 add %al,(%rax) + 1000103d: 00 00 add %al,(%rax) + ... + +0000000010001040 <__DTOR_LIST__>: + 10001040: ff (bad) + 10001041: ff (bad) + 10001042: ff (bad) + 10001043: ff (bad) + 10001044: ff (bad) + 10001045: ff (bad) + 10001046: ff (bad) + 10001047: ff 00 incl (%rax) + 10001049: 00 00 add %al,(%rax) + 1000104b: 00 00 add %al,(%rax) + 1000104d: 00 00 add %al,(%rax) + ... diff --git a/weak/b.c b/weak/b.c new file mode 100644 index 0000000..c7a1f11 --- /dev/null +++ b/weak/b.c @@ -0,0 +1,7 @@ +int sym(int x); + +int test(int x) +{ + return sym(x)*2; +} + diff --git a/weak/b.o b/weak/b.o new file mode 100644 index 0000000..45beb82 Binary files /dev/null and b/weak/b.o differ diff --git a/weak/b.o.dis b/weak/b.o.dis new file mode 100644 index 0000000..72c0677 --- /dev/null +++ b/weak/b.o.dis @@ -0,0 +1,13 @@ + +b.o: Dateiformat pe-x86-64 + + +Disassembly of section .text: + +0000000000000000 : + 0: 48 83 ec 28 sub $0x28,%rsp + 4: e8 00 00 00 00 callq 9 + 5: R_X86_64_PC32 sym + 9: 01 c0 add %eax,%eax + b: 48 83 c4 28 add $0x28,%rsp + f: c3 retq -- cgit v1.2.3