I have a script like this to create and ELF file for a ARM CPU. SECTIONS { .text 0x00100000 : { . = ALIGN(64); *(.text) } :text .data 0x00200000 : AT(ADDR(.text) + SIZEOF(.text)) { . = ALIGN(4); *(.data) } :data .bss : AT(LOADADDR(.data) + SIZEOF(.data)) { . = ALIGN(4); *(.bss) } :data /DISCARD/ : { *(*) } }
This worked fine until I started using code that required ARM/Thumb interworking. Then the app crashed. The disassembly showw that calls to the functions requiring interworking look like this: Address opcode mnemonic comment ... 1299a8: ebfb5994 bl 0 ;call foo1() ... 1299e4: ebfb5988 bl c ;call foo2() ... 129a24: ebfb597b bl 18 ;call foo3() ... So I have an elf file, with wired jumps (like "bl 0") instead of the correct interworking function calls. I found out that the interworking feature creates two new "magic" sections called .glue_7 and .glue_7t. Unfortunately, the "/DISCARD/" block in my linker script removes them. So the quick solution is to add *(.glue_7) and *(.glue_7t) to my linker script. I admint, that it is my fault that the stub code from .glue_7/.glue_7t is missing. But I would still expect an error to be thrown here. When I look at the interworking stubs from .glue_7/.glue_7t I find this symbols. 0013f670 __foo1_from_arm 0013f67c __foo2_from_arm 0013f688 __foo3_from_arm So, what seem to happen is this. If you look at the "bl x" above and the addresses of the stubs, it seem that ld still puts the relative offsets right. It's just the offset of the discarded sections .glue_7/.glue_7t that is set to zero or not added at all. Why doesn't ld throw an error here, that .glue_7/.glue_7t simply cannot be discarded, because the code will no longer work correctly? -- Summary: Discarded Sections with references don't cause errors (ARM/Thumb interworking) Product: binutils Version: 2.15 Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: axelheider at gmx dot de CC: bug-binutils at gnu dot org http://sourceware.org/bugzilla/show_bug.cgi?id=4638 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils