Author Topic: Polink better ?  (Read 18006 times)

Magnum

  • Member
  • *****
  • Posts: 2399
Polink better ?
« on: April 28, 2013, 12:22:12 AM »
Is it better to use polink instead of link.exe ?

If so, can I substitute it for link in my batch files ?

Thanks.
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: Polink better ?
« Reply #1 on: April 28, 2013, 02:41:32 AM »
Hi Andy,

Is it better to use polink instead of link.exe ?

If so, can I substitute it for link in my batch files ?

Thanks.

I think that both linkers are quiet good. If you're programming with ml why not use the native linker? During my first attempts with ml 5 (or so) in the 80s I've had some difficulties with the MS linker, because it did generate false addresses in COM files. I had to patch in the right addresses by hand with the hex tool of the Norton Commander. I've solved that question by using TASM and TLINK. But these times are over, I guess.

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

Vortex

  • Moderator
  • Member
  • *****
  • Posts: 2787
Re: Polink better ?
« Reply #2 on: April 28, 2013, 02:55:31 AM »
Hi Magnum,

Quote
If so, can I substitute it for link in my batch files ?

Yes, you can. Polink is a powerful linker.

japheth

  • Guest
Re: Polink better ?
« Reply #3 on: April 28, 2013, 03:16:17 AM »
Quote
If so, can I substitute it for link in my batch files ?

Yes, you can.

You can ... usually. However, if debug info is to be generated (-Zi), you should be aware that polink won't understand the info if Masm v8 or newer has been used. Also, the debug info written by polink might not be comprehensible for MS Visual C or WinDbg. OTOH, if you want to use the debugger integrated into POIDE, using polink is virtually a must.





Magnum

  • Member
  • *****
  • Posts: 2399
Re: Polink better ?
« Reply #4 on: April 28, 2013, 04:20:12 AM »
Thanks guys for the info.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Polink better ?
« Reply #5 on: April 28, 2013, 04:21:10 AM »
i wouldn't say PoLink is "better", just different
it can generate smaller files with the normal switches

however, MS Link is a very good tool, perhaps more versatile, more options
it can generate smaller files as well, by combining sections, etc

Magnum

  • Member
  • *****
  • Posts: 2399
Re: Polink better ? and Carb help
« Reply #6 on: April 28, 2013, 05:32:50 AM »
I would like to stick with link.

How do I combine sections ?


OFF TOPIC subject Carbs

I am rusty with carbeurators.

I found gas in the bottom of the air filter holder for a sears mower.

Took the fuel bowl off.
I think I need to adjust the float but the float is plastic with no adjustment tab.

In the old days, I think the "tang" could be adjusted.

I want to adjust the needle so it makes contact sooner to stop the gas flow.

Any other way to adjust it ?

Thanks.
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Polink better ?
« Reply #7 on: April 28, 2013, 08:46:01 PM »
here are a few LINK lines i was playing with...
Code: [Select]
Link /SUBSYSTEM:CONSOLE /OPT:NOREF /MERGE:.data=.text /ALIGN:4 %1.obj
Link /SUBSYSTEM:CONSOLE /OPT:NOREF /MERGE:.data=.text /ALIGN:16 %1.obj
Link /SUBSYSTEM:CONSOLE /OPT:NOREF /MERGE:.data=.text %1.obj
you may have to use different alignment, depending on your code
for example, some SSE data needs to be 16-aligned

Magnum

  • Member
  • *****
  • Posts: 2399
Re: Polink better ?
« Reply #8 on: April 30, 2013, 12:18:26 PM »
This results in a better than 1000 byte savings if the data section is eliminated.
It looks like the minimum size that is allocated is 1024 byte chunks.

I guess it would only be useful if all you had was text.

Code: [Select]
start:

jmp next

string db    "Now is the time.",0

next:

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Polink better ?
« Reply #9 on: April 30, 2013, 07:04:28 PM »
there are other kinds of constant data, like look-up tables, etc, too
but, there may be some side-effects in the way data and code are cached

Vortex

  • Moderator
  • Member
  • *****
  • Posts: 2787
Re: Polink better ?
« Reply #10 on: May 01, 2013, 04:00:46 AM »
Hi Magnum,

I use polink since 8 years and I didn't have any serious problem.

jj2007

  • Member
  • *****
  • Posts: 13932
  • Assembly is fun ;-)
    • MasmBasic
Re: Polink better ?
« Reply #11 on: August 20, 2013, 08:29:34 AM »
Today I stumbled into an odd behaviour of polink:
  ORG $+BufLen-1
;   db ?
Without the db ?, data was overwritten. MS link doesn't do that...
However, I haven't been able to isolate this behaviour - the snippet below works.

include \masm32\include\masm32rt.inc

crtbuf MACRO var, BufLen, msAlign:=<4>   ; cb pBuffer, 1000 [, 16]
LOCAL cblabel
.data?
align msAlign
  cblabel LABEL BYTE
  var equ offset cblabel
  ORG $+BufLen-1
;   db ?
.code
ENDM

.data?
somevalue   dd ?

.code
start:   crtbuf buffer, 80
   mov eax, offset buffer
   int 3
   invoke lstrcpy, offset buffer, chr$("This is a text that is exactly 44 bytes long")
   print offset buffer, 13, 10
   mov somevalue, "tihs"  ; no effect
   print offset buffer, 13, 10
   exit

end start


Antariy

  • Member
  • ****
  • Posts: 564
Re: Polink better ?
« Reply #12 on: August 20, 2013, 10:41:56 AM »
Today I stumbled into an odd behaviour of polink:
  ORG $+BufLen-1
;   db ?
Without the db ?, data was overwritten. MS link doesn't do that...
However, I haven't been able to isolate this behaviour - the snippet below works.

How much data was overwritten in the case when this behaviour showed itself?

BTW, why ORG $+BufLen-1, not ORG $+BufLen? May not it be a reason?

jj2007

  • Member
  • *****
  • Posts: 13932
  • Assembly is fun ;-)
    • MasmBasic
Re: Polink better ?
« Reply #13 on: August 20, 2013, 12:04:15 PM »
How much data was overwritten in the case when this behaviour showed itself?
Quite a lot, as if polink had decided to merge a segment, ignoring the ORG.

Quote
BTW, why ORG $+BufLen-1, not ORG $+BufLen? May not it be a reason?
It was actually ORG $+BufLen. The "-" was added for the extra db ?

Will try tomorrow if I find my test case on the other puter.

Antariy

  • Member
  • ****
  • Posts: 564
Re: Polink better ?
« Reply #14 on: August 20, 2013, 12:12:27 PM »
Quote
BTW, why ORG $+BufLen-1, not ORG $+BufLen? May not it be a reason?
It was actually ORG $+BufLen. The "-" was added for the extra db ?

Ah, it's clear now.

Will try tomorrow if I find my test case on the other puter.

It seems I get - you need to define "somevalue" after you defined a buffer. I.e. like this:



.code
start:   crtbuf buffer, 80
   mov eax, offset buffer
.data?
somevalue   dd ?
.code
   int 3
   invoke lstrcpy, offset buffer, chr$("This is a text that is exactly 44 bytes long")
   print offset buffer, 13, 10
   mov somevalue, "tihs"  ; no effect
   print offset buffer, 13, 10
   exit

end start


Will check it now.