flat assembler
Message board for the users of flat assembler.
Index
> Main > invalid use of symbol (???) |
Author |
|
vid 15 May 2011, 14:08
Seems COFF doesn't have "-value" relocation. Use two instructions. And yes, better error message is really needed
|
|||
15 May 2011, 14:08 |
|
ouadji 15 May 2011, 15:10
1 - 0x00000002 = 1+(0-0x00000002) = 1 + 0xFFFFFFFE If "FASM" knows the value of "A", then it can easily compute "1-A ". it's not a matter about the format coff, but a matter about fasm compiler. I really don't see where is the problem! Code: format MS COFF mov eax, A_2 ; ok mov eax, - A_2 ; does not compile ;Yet, "-A2" is simply equal to "neg A2" !!! A_2: |
|||
15 May 2011, 15:10 |
|
LocoDelAssembly 15 May 2011, 16:25
fasm only knows that A_2 is at some distance of an unknown base address.
Lets suppose A_2 is at distance zero of base address (something that happens if you place the "A_2:" just below "format MS COFF", check with a hex editor using the non negative address), what value would you expect fasm to place in the imm32 part of the instruction so that the linker can latter fix by adding the link-time base address? (remember, if the link-time address is in the [0..2^31 - 1] range then eax must be loaded with a negative value at run-time, and if the address is in the [2^31-..2^32 - 1] range then eax should have a positive value at run-time) [edit]These are the relocation types available: Intel 386 Processors IMAGE_REL_I386_ABSOLUTE 0x0000 The relocation is ignored. IMAGE_REL_I386_DIR16 0x0001 Not supported. IMAGE_REL_I386_REL16 0x0002 Not supported. IMAGE_REL_I386_DIR32 0x0006 The target’s 32-bit VA. IMAGE_REL_I386_DIR32NB 0x0007 The target’s 32-bit RVA. IMAGE_REL_I386_SEG12 0x0009 Not supported. IMAGE_REL_I386_SECTION 0x000A The 16-bit section index of the section that contains the target. This is used to support debugging information. IMAGE_REL_I386_SECREL 0x000B The 32-bit offset of the target from the beginning of its section. This is used to support debugging information and static thread local storage. IMAGE_REL_I386_TOKEN 0x000C The CLR token. IMAGE_REL_I386_SECREL7 0x000D A 7-bit offset from the base of the section that contains the target. IMAGE_REL_I386_REL32 0x0014 The 32-bit relative displacement of the target. This supports the x86 relative branch and call instructions.[/edit] |
|||
15 May 2011, 16:25 |
|
ouadji 15 May 2011, 19:24
Thank you Loco, ok, I really begin to understand. Thank you for taking the time to explain. The coff format is more complicated than I thought. I'll buy a good book about this topic. It is time for me to get to the bottom of things and understand it in depth! |
|||
15 May 2011, 19:24 |
|
ouadji 15 May 2011, 20:48
here's a better error message for this case. (that "invalid use of symbol") Code: ;EXPRCALC.INC ;------------ invalid_sub: cmp [error_line],0 jne sub_values mov eax,[current_line] mov [error_line],eax mov [error],invalid_subtraction jmp sub_values ;ERRORS.INC ;---------- invalid_subtraction: push _invalid_subtraction jmp error_with_source ;MESSAGES.INC ;------------ _invalid_subtraction db ' invalid subtraction',0 |
|||
15 May 2011, 20:48 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.