News:

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

Main Menu

UASM 2.57

Started by johnsa, August 11, 2024, 07:51:42 AM

Previous topic - Next topic

johnsa

I think shared libraries depend on PLT and GOT - much like PIE executables, neither of which are supported - and for years there has been no clear or logical way to support them.

Without a HLL language/compiler to infer the plt/got stuff I've not seen any assembler actually solve this.
YASM had something - but it's dead and never worked right, I don't know the state of NASM in this regard, there was a whole bunch of awful filth about using ..wrt operator.

I don't really work on Linux so I'm no expert, but happy for someone to help try and solve things - as far as I can tell from my albeit limited perspective, Linux is a piece of sh1t and designed by C programmers who clearly hate assembly language. :)

mineiro

#16
I'm not a C programmer, so I can't help in this sense.
My investigation tolds me that if a shared library don't use internally a call to an external function that exist in a library, so that works fine. The main problem that I faced was when calling an external function that exist in a library.

native.asm
;not modified uasm without calling a function in an external library
;uasm -elf64 -pie native.asm
;ld --no-dynamic-linker -pie -e _start -o native native.o

;or using plugin.o from previous post
;uasm -elf64 -pie native.asm
;gcc -shared -o libplugin.so plugin.o native.o

.x64
.data
hello db "hello",10,0


.code
public _start
_start:
public quit
quit:

    mov rax,1
    mov rdi,1
    lea rsi,hello
    mov rdx,sizeof hello
    syscall

    mov rax,60
    mov rdi,0
    syscall


;end _start
end

Position independent code is working in my tests too (with modified uasm from previous post).
pie.asm
;modified uasm
;uasm -elf64 pie.asm
;gcc -lc -pie pie.o -o pie

.X64
option casemap:none

printf proto :vararg
exit proto :dword

.code
public main
main proc uses r12 argc:dword, argv:ptr
; call @F
;@@:
; pop r12
; sub r12,$-main

lea r12,main
invoke printf,CStr("%016llx",10),r12
    invoke exit,0
main endp

end main

results from program above run multiple times (checked with debugger too):
./pie
0000555841760150
000055e0f34cc150
00005591c59ca150
...

edited: lea r12, main
I was thinking in a switch in uasm command line to elf64, that description is something like "use R_X86_64_PLT32 instead of R_X86_64_PC32".
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

tenkey

PROC directive appears to be broken. It doesn't list the PROC line and affects the following line.

Example:

The original source:

xWinMain PROC

invoke DialogBoxIndirectParam, InstanceHandle, addr TheDialogTemplate, NULL, addr TheDialogProc, NULL

XOR EAX, EAX

The listing:

00000031                    00000031  4883EC08          *   sub rsp, 8
          invoke __im00000035                    nstanceHandle, addr TheDialogTemplate, NULL, addr TheDialogProc, NULL
0000002D                    *   sub rsp, 48
00000035  4883EC30           *    mov rcx, In00000039  488B0D00000000                  *    lea rdx, Th00000040  488D1500000000                     *    xor r8d, r800000047  4533C0               *    lea r9, The0000004A  4C8D0D00000000                *    mov qword p00000051  48C744242000000000                   *    call __imp_0000005A  FF1500000000      00059                    *    add rsp, 48000000000064  33C0                  XOR EAX, EAX

The command line:

uasm -win64 -Fl -Sg -Sn GOL.asm
One file, several examples: You cannot view this attachment.

lucho

Thanks, John, for continuing the development of UASM! I've now built version 2.57 also for macOS, Solaris, FreeBSD, NetBSD and OpenBSD, so if anyone needs some of these binaries, please let me know.

Unfortunately, UASM can only generate debug information for Windows, so these builds cannot generate one for the corresponding operating system they've been built for.

Lucho

2B||!2B

#19
Thanks for the update.

With this new version, I'm occasionally getting error from the linker

fatal error LNK1103: debugging information corrupt; recompile module
This error didn't exist in 2.56 version.
This is UASM64.

For UASM32 2.57, there are also bugs with the linker
The 32-bit linker ... ran out of heap space and is going to restart linking with a 64-bit linker
But if I use the 64 linker,
Another error shows up
link : fatal error lnk1102: out of memory
I'm not sure what changed in 2.57 that broke this.
For now I will just stick to 2.56.