News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Linker error

Started by nirmalarasu, June 05, 2015, 02:19:35 AM

Previous topic - Next topic

nirmalarasu

Hello,

i have installed MASM 8.00 and finding this linker error  with MASM.
*fatal error LNK1190: invalid fixup found, type 0x0001*

Let me know if any environmental settings required to be changed


C:\ LINUXLDR>ml LINUXLDR.Asm
Microsoft (R) Macro Assembler Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

Assembling: LINUXLDR.Asm
LINUXLDR.Asm(404) : warning A4023: with /coff switch, leading underscore required for start address :
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

/OUT:LINUXLDR.exe
LINUXLDR.obj
LINUXLDR.obj : fatal error LNK1190: invalid fixup found, type 0x0001

hutch--

Rough guess without seeing what you have done or where the code comes from is the object module type is wrong. Bit more info would be useful.

rrr314159

Other people on this board know a lot more than me about object models; your problem has to do with that. I assemble with /coff option, and use separate linker stage; this works.

ML /c /coff yourprog.asm

link /subsystem:console yourprog.obj /out:yourprog.exe

Try it like that it should work; altho there are other ways to do it.
I am NaN ;)

Gunther

Hi nirmalarasu,

first things first: Welcome to the forum.

Could you post your used command line switches for linking, please?

Gunther
You have to know the facts before you can distort them.

rrr314159

he's not using separate liner stage!, just ML with no switches. ML does the linking for u in that case, simply by calling the linker. U can pass the linker switches on the ML line but,

Seems easier the way I do it, /c to tell ML separate linker, /coff for object model, /subsystem:console on linker: that works
I am NaN ;)

MtheK

FYI
  Not sure if this will help, but I remember getting this when I was trying this:

;         LEA   EBX,COPYRIGHT
;$IDNUM0  EQU   $
;* WHAT THE HELL??? CAN ONLY DO 'LEA' in .data?????!!!!!
;* SLEEP.obj : fatal error LNK1190: invalid fixup found, type 0x0001
;*  asmlnk32 C: 1190 LINK
;         LEA   EBX,$IDNUM0

I could never figure it out, so I commented it all out. It seems that the content
of my assembler source actually caused it for me since, when commented,
but using the same .BAT I always use, it then worked OK...

rrr314159

I'm no expert but,

you can't lea a symbol like $IDNUM0, since it has no address. If "COPYRIGHT" was also symbolic same thing applies.

"invalid fixup" means the linker couldn't "fix" an address ... when you correctly refer to an address in code, assembler doesn't yet know the actual address when linked, only the relative addr to the module's beginning. (There are exceptions with old-fashioned code which might not need a linker, not applicable here). So assembler passes it along to linker, telling it to "fix" the address when the .exe gets put together. One way to get the error, then, is to treat symbolic constant as an address (like a real data statement). Another way, if your object model is wrong; there are many ways that can happen, simplest (i.e. easiest to correct) is assembler not telling linker correct obj model. I think here we have one example of each problem.

BTW above description not the same as when the .exe is actually loaded into memory; then the loader makes the final adjustments depending on the start of program in mem.

If I'm wrong about any of that I'm not surprised ... ! But I still think my recommendation may fix nirmalarasu's problem
I am NaN ;)

Gunther

Quote from: rrr314159 on June 05, 2015, 03:39:19 PM
But I still think my recommendation may fix nirmalarasu's problem

Yes, that should work.

Gunther
You have to know the facts before you can distort them.

hutch--

It still sounds like an incompatible object module that the linker does not understand. There has only been one post and we don't really have enough information but I suspect that at least one object module is not a valid Microsoft COFF format file.

sinsi

Sounds like 16-bit code and trying to use the 32-bit linker.Try using link16 instead, although that won't work in win64.

MtheK

  Hmmm, an EQU is not an address? I guess this is just another PC difference
btx the mainframe. Bummer! In the mainframe, '$IDNUM0' would have a virtual
address; in my case, it would point to the "LEA" instruction:

$IDNUM0   EQU   *
                  LA      R15,$IDNUM0               

  I tried it again, but got the same LINK failure.

  I added this to my assembler sample program source which
assembles and links OK B 4 this:

DUMMYMAC MACRO A,B
         LOCAL $IDNUM0
$IDNUM0  EQU   $
         LEA   EBX,$IDNUM0
         ENDM

...

        .CODE

...

         DUMMYMAC

which generated this in .lst:

                     DUMMYMAC
              1            LOCAL $IDNUM0
00000000 = 00000000        1   ??0023  EQU   $
00000000  67& 8D 1E 0000 R  1            LEA   EBX,??0023



yet, tho the assembly worked, the LINK failed:

Processed /DEFAULTLIB:kernel32.lib

Start Pass1
SAMPLE.obj : fatal error LNK1190: invalid fixup found, type 0x0001

MtheK

  HAH! F*#&IN' A! Thankx to u stirring up my memories, I fixed my problem!
I used an old mainframe trick. I changed the EQU to a DS 0C (BYTE):

DUMMYMAC MACRO A,B
         LOCAL $IDNUM0
;$IDNUM0  EQU   $
$IDNUM0  BYTE 0 DUP(?)
         LEA   EBX,$IDNUM0
         ENDM

TOTALLY COOL! It assembles, it links, it runs, and its' verified
that EBX has its' address:

Breakpoint 0 hit
eax=774b1102 ebx=7ffdb000 ecx=00000000 edx=00401000 esi=00000000 edi=00000000
eip=00401000 esp=0012ff8c ebp=0012ff94 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
SAMPLE!??0023:
00401000 8d1d00104000    lea     ebx,[SAMPLE!??0023 (00401000)]
0:000> t
eax=774b1102 ebx=00401000 ecx=00000000 edx=00401000 esi=00000000 edi=00000000
eip=00401006 esp=0012ff8c ebp=0012ff94 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
SAMPLE!??0023+0x6:
00401006 b864000000      mov     eax,64h

TOTALLY, TOTALLY COOL!!! Too bad I already found a different way (LOC over addr), but I think, from now on, for me, I will do this. Thankx!

rrr314159

congrats MtheK,

hope nirmalarasu is equally happy!

That "trick" makes sense, converts symbolic constant into data address ... no logical difference perhaps but assembler / linker now treats it as u want. I've done similar thing, but never occurred to me use db 0 ... why not, saves a byte, and is "cool"!
I am NaN ;)

Gunther

Hi MtheK,

that's indeed a very cool trick. It'll work with 64-bit too, I hope.

Gunther
You have to know the facts before you can distort them.