NO

Author Topic: polink issue ?  (Read 1149 times)

Offline jk

  • Member
  • *
  • Posts: 7
Re: polink issue ?
« Reply #15 on: August 26, 2023, 05:20:26 PM »
My bad, it should have been "DWORD" (my setup maps XWORD to DWORD/QWORD in 32/64 bit respectively)

This is what i get with podump:
Code: [Select]
Dump of Test.obj

File type: OBJ

SYMBOL TABLE
0000 00000000 DEBUG  notype      filename     | .file
     C:\Users\Juergen\Desktop\Pelle\Test.tmp
0004 00000000 SECT1  notype      static       | .text
     length of section   53, #relocations    3, #linenumbers    0
0006 00000000 SECT2  notype      static       | .data
     length of section    0, #relocations    0, #linenumbers    0
0008 00000000 SECT3  notype      static       | .drectve
     length of section   28, #relocations    0, #linenumbers    0
000A 00000000 UNDEF  notype ()   external     | _ExitProcess@4
000B 00000000 SECT1  notype ()   external     | _TESTME@0
000C 00000027 SECT1  notype ()   external     | _start@0
000D 0000000B SECT1  notype      label        | ___el1
000E 00000038 SECT1  notype      label        | ___el1


The offending line in your disassembly is:
Code: [Select]
lea     ebx, [start.__el1]
which is correct, so no problem here

Assembling it with the other assemblers and linking it with polink results in this (as if the code in start proc would have been like so):
Code: [Select]

lea     ebx, [TESTME.__el1]

Obviously poasm creates symbols in a different way and polink expects such symbols ...

As you can see in my dump, the symbol "___el1" is listed twice and there isn´t a prefix indicating the corresponding procedure, which, as it seems, polink needs to get things straight, while MS´s linker can handle it nevertheless.

So definitely not a bug, because polink is tailored for po...  things, but because of these special things polink cannot be used for linking everything.

Maybe i´m still overlooking something...  A pity - polink would have been a lightweight alternative to MS´s bloated stuff. Anyway, thanks for your help and contributions!

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: polink issue ?
« Reply #16 on: August 26, 2023, 06:37:24 PM »
So definitely not a bug, because polink is tailored for po...  things, but because of these special things polink cannot be used for linking everything.

Maybe i´m still overlooking something...  A pity - polink would have been a lightweight alternative to MS´s bloated stuff. Anyway, thanks for your help and contributions!
Good to know that the issue is solved.  :)
I'll remove it from the bug reports thread to avoid confusion.
Anyway it's always unsafe to expect that MS things are conformant to any standard...  ;D
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline John Z

  • Member
  • *
  • Posts: 796
Re: polink issue ?
« Reply #17 on: August 26, 2023, 08:29:03 PM »
Good work Vortex!  Thanks for answering the call  :) :) :)

John Z

Offline Vortex

  • Member
  • *
  • Posts: 802
    • http://www.vortex.masmcode.com
Re: polink issue ?
« Reply #18 on: August 26, 2023, 09:41:00 PM »
Hi John,

You are welcome, thanks.

Hi jk,

It would be preferable to give unique and more descriptive names to your labels to avoid conflicts.

Assembling the code with MS Macro Assembler supplied with the Masm32 package :

Code: [Select]
E:\PellesC\Bin>\masm32\bin\ml.exe /c /coff test.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: test.asm

Trying to link the object module with Polink :

Code: [Select]
E:\PellesC\Bin>polink.exe /SUBSYSTEM:WINDOWS test.obj \PellesC\lib\Win\kernel32.lib
POLINK: error: Symbol '__el1' is multiply defined: 'test.obj' and 'test.obj'.

The output of MS Macro Assembler :

Code: [Select]
_TESTME@0 PROC NEAR
        push    ebp                                     ; 0000 _ 55
        mov     ebp, esp                                ; 0001 _ 8B. EC
        add     esp, -4                                 ; 0003 _ 83. C4, FC
        push    ebx                                     ; 0006 _ 53
        push    esi                                     ; 0007 _ 56
        push    edi                                     ; 0008 _ 57
        xor     eax, eax                                ; 0009 _ 33. C0

__el1   LABEL NEAR
        test    eax, eax                                ; 000B _ 85. C0
        jnz     ?_002                                   ; 000D _ 75, 11
        lea     ebx, [__el1]                            ; 000F _ 8D. 1D, 00000000(d)
        mov     dword ptr [ebp-4H], ebx                 ; 0015 _ 89. 5D, FC
        jmp     ?_001                                   ; 0018 _ EB, 00

?_001:  add     eax, 1                                  ; 001A _ 83. C0, 01
        jmp     dword ptr [ebp-4H]                      ; 001D _ FF. 65, FC
_TESTME@0 ENDP

?_002   LABEL NEAR
        pop     edi                                     ; 0020 _ 5F
        pop     esi                                     ; 0021 _ 5E
        pop     ebx                                     ; 0022 _ 5B
        leave                                           ; 0023 _ C9
        ret                                             ; 0024 _ C3

_start@0 PROC NEAR
        push    ebp                                     ; 0025 _ 55
        mov     ebp, esp                                ; 0026 _ 8B. EC
        add     esp, -4                                 ; 0028 _ 83. C4, FC
        push    ebx                                     ; 002B _ 53
        push    esi                                     ; 002C _ 56
        push    edi                                     ; 002D _ 57
        call    _TESTME@0                               ; 002E _ E8, FFFFFFCD
        xor     edx, edx                                ; 0033 _ 33. D2

__el1   LABEL NEAR
        test    edx, edx                                ; 0035 _ 85. D2
        jnz     ?_004                                   ; 0037 _ 75, 11
        lea     ebx, [__el1]                            ; 0039 _ 8D. 1D, 00000000(d)
        mov     dword ptr [ebp-4H], ebx                 ; 003F _ 89. 5D, FC
        jmp     ?_003                                   ; 0042 _ EB, 00
« Last Edit: August 26, 2023, 10:41:45 PM by Vortex »
Code it... That's all...

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: polink issue ?
« Reply #19 on: August 28, 2023, 10:01:05 AM »
I tried ml (2013) with -Gy option and result crashed.
Code: [Select]
.386
.model flat, stdcall

ExitProcess PROTO :DWORD
TESTME PROTO

includelib KERNEL32.LIB


.CODE


TESTME PROC USES EBX ESI EDI
;*************************************************************************************
;
;*************************************************************************************
LOCAL _res:DWORD


  xor eax, eax


__el1:
  test eax, eax
  jne L2


  lea ebx, __el1
  mov _res, ebx
  jmp L1   ;jmp to error handler


; some other code


L1:
  add eax, 1
  JMP _res


L2:


RET


TESTME ENDP


start PROC USES EBX ESI EDI
;*************************************************************************************
;
;*************************************************************************************
LOCAL _res:DWORD


  invoke TESTME


int 3
  xor edx, edx


__el1:
  test edx, edx
  jne L2


  lea ebx, __el1
  mov _res, ebx
  jmp L1   ;jmp to error handler


; some other code


L1:
  add edx, 1
  JMP _res


L2:

INVOKE ExitProcess, edx
  ret

start ENDP


END start

Code: [Select]
00000000  55                       push ebp
00000001  8BEC                     mov ebp, esp
00000003  83C4FC                   add esp, -4h
00000006  53                       push ebx
00000007  56                       push esi
00000008  57                       push edi
00000009  33C0                     xor eax, eax
0000000B  85C0                     test eax, eax
0000000D  7511                     jnz L_20
0000000F  8D1D0B104000             lea ebx, [$+40100Bh]
00000015  895DFC                   mov dword ptr [ebp-4h], ebx
00000018  EB00                     jmp L_1A
0000001A  83C001                   add eax, 1h
0000001D  FF65FC                   jmp dword ptr [ebp-4h]
00000020  5F                       pop edi
00000021  5E                       pop esi
00000022  5B                       pop ebx
00000023  C9                       leave
00000024  C3                       ret
00000025  CC                       int3
00000026  CC                       int3
00000027  CC                       int3
00000028  55                       push ebp
00000029  8BEC                     mov ebp, esp
0000002B  83C4FC                   add esp, -4h
0000002E  53                       push ebx
0000002F  56                       push esi
00000030  57                       push edi
00000031  E8CAFFFFFF               call $-31h
00000036  CC                       int3
00000037  33D2                     xor edx, edx
00000039  85D2                     test edx, edx
0000003B  7511                     jnz L_4E
0000003D  8D1D39104000             lea ebx, [$+401039h]
00000043  895DFC                   mov dword ptr [ebp-4h], ebx
00000046  EB00                     jmp L_48
00000048  83C201                   add edx, 1h
0000004B  FF65FC                   jmp dword ptr [ebp-4h]
0000004E  52                       push edx
0000004F  E806000000               call $+Bh
00000054  5F                       pop edi
00000055  5E                       pop esi
00000056  5B                       pop ebx
00000057  C9                       leave
00000058  C3                       ret
00000059  CC                       int3
0000005A  FF2500204000             jmp dword ptr [$+402000h]
« Last Edit: August 28, 2023, 11:36:47 AM by TimoVJL »
May the source be with you

Offline Vortex

  • Member
  • *
  • Posts: 802
    • http://www.vortex.masmcode.com
Re: polink issue ?
« Reply #20 on: August 29, 2023, 07:28:03 PM »
Source code assembled with ml V14.29.30151.0 and object file linked with link V5.12.8078. No any crash.
Code it... That's all...

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: polink issue ?
« Reply #21 on: August 30, 2023, 03:23:28 PM »
test was done with 14.33.31630.0
hopefully test asm source was same as i used and isn't reason for crash.
no downloads, so not with same source.
May the source be with you