From: Lars M. <lar...@te...> - 2014-10-04 20:35:19
|
Hi, today and yesterday I worked a bit at the feature we previously talked about. This is not as easy as it might seems to be. It took very long for me to understand the programm mechanics. Now I'm at the following point: I can record extern definitions and prevent nasm from passing them to the ofmt. Although a redefinition as global is possible and they were treated as "unseen" labels. So the old function of a global label still works. There is just one problem: when passing the recorded extern labels, exept those wich are globals now, after the assembling is done, then the reloc adresses are broken in the output file. I guess this is because while assembling nasm is unable to resolve the label references. I would fix this, but I have no idea where and when this resolving takes places? Just to make the problem clearer: nasm -f elf test\externdef.asm [extern externFunc] [extern externFunc2] [extern myFunc] [global myFunc] [section .text use32 class=code] ; just some senseless code to create references and relocs myFunc: push ebp mov ebp, esp .local: mov eax, 0x01 jmp .local leave ret 4 abc: call [externFunc] call [externFunc2] call [myFunc] ret 4 objdump -x test\externdef.o nasm-2.11.05\test\externdef.o: file format elf32-i386 nasm-2.11.05\test\externdef.o architecture: i386, flags 0x00000011: HAS_RELOC, HAS_SYMS start address 0x00000000 Sections: Idx Name Size VMA LMA File off Algn 0 .text 00000023 00000000 00000000 00000130 2**4 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE SYMBOL TABLE: 00000000 l df *ABS* 00000000 test\externdef.asm 00000000 l d .text 00000000 .text 00000003 l .text 00000000 myFunc.local 0000000e l .text 00000000 abc 00000000 *UND* 00000000 externFunc 00000000 *UND* 00000000 externFunc2 00000000 g .text 00000000 myFunc RELOCATION RECORDS FOR [.text]: OFFSET TYPE VALUE 00000010 R_386_32 myFunc 00000016 R_386_32 myFunc 0000001c R_386_32 myFunc |