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 and "Set object file name"

Started by mabdelouahab, July 25, 2019, 04:39:30 PM

Previous topic - Next topic

mabdelouahab

Hi
I have some applications in Ubuntu, I want to use UASM
I noticed that when I use

    uasm -elf64 main.asm

I get file object named main.o

and when I specifed the file object name by using -Fo I will not get any file object

    uasm -elf64 main.asm -Fo=TmpObject.o


johnsa

I'll investigate that.

Thanks for reporting.

mabdelouahab


;----------------------------------------------------------
Proc_Helper MACRO _n:REQ,_St:REQ,_Args:VARARG
% ECHO Befer = _Args
    .CODE
    _St PROC _Args
% ECHO After= _Args
        FOR __Arg,<_Args>
            %echo MOV RAX,__Arg 
        ENDM
        ret
    _St ENDP
ENDM

Proc_Helper   0,Proc1  ,arg01,arg02,arg03,arg04,arg05,arg06,arg07,arg08,arg09
;----------------------------------------------------------


Befer= arg01,arg02,arg03,arg04,arg05,arg06,arg07,arg08,arg09
After= edi,esi,edx,ecx,r8d,r9d,arg07,arg08,arg09
MOV RAX,edi 
MOV RAX,esi 
MOV RAX,edx 
MOV RAX,ecx 
MOV RAX,r8d 
MOV RAX,r9d 
MOV RAX,arg07 
MOV RAX,arg08 
MOV RAX,arg09


Why values ​​have changed?

johnsa

Can you provide an example source using that macro? How are arg0-n defined?
It looks like it's assuming SYS-V ABI ?

mabdelouahab

Quote from: johnsa on July 28, 2019, 08:55:34 PM
It looks like it's assuming SYS-V ABI ?

You're right, is SystemV ABI, the parameters when referenced by name actually refer to registers  :thumbsup:



Proc_Helper MACRO _n:REQ,_St:REQ,_Args:VARARG
% ECHO Befer PROC  = _Args
    .CODE
    _St PROC SYSTEMV _Args
% ECHO After PROC  = _Args
        ret
    _St ENDP
% ECHO After ENDP  = _Args
ENDM

Proc_Helper   0,Proc1  ,arg01:qword,arg02,arg03,arg04,arg05,arg06,arg07,arg08,arg09
.code
main PROC SYSTEMV   
    xor rax,rax
    ret
main ENDP
end


Befer PROC  = arg01:qword,arg02,arg03,arg04,arg05,arg06,arg07,arg08,arg09
After PROC  = rdi:qword,esi,edx,ecx,r8d,r9d,arg07,arg08,arg09
After ENDP  = arg01:qword,arg02,arg03,arg04,arg05,arg06,arg07,arg08,arg09
program.asm: 21 lines, 3 passes, 2667 ms, 0 warnings, 0 errors


mabdelouahab

#5
Quote from: johnsa on July 28, 2019, 08:55:34 PM
Can you provide an example source using that macro? How are arg0-n defined?
I think I found a better way than the first one
include sys_call_x64.inc
stdout    equ 1
.data
    _str db "Example sys_write",0
.code
main PROC SYSTEMV
    invoke _write, stdout, addr _str, 17
    xor rax,rax
    ret
main ENDP
end


sys_call_x64.inc:

; from: /usr/include/x86_64-linux-gnu/asm/unistd_64.h
ifndef _ASM_X86_UNISTD_64_H
    _ASM_X86_UNISTD_64_H EQU 1
   
   ; include sys_call_x64_constants.inc  ;SYSCALL Constants


    _SYSCALL_DEF MACRO _St,_n
        .code
        _St PROC SYSTEMV _Args_:VARARG
           MOV R10,RCX ; SYSCALL uses R10 instead of RCX
           MOV RAX,_n
           SYSCALL
           RET
        _St ENDP
    ENDM
   
    _SYSCALL_DEF _read, 0
    _SYSCALL_DEF _write, 1
    _SYSCALL_DEF _open, 2
    _SYSCALL_DEF _close, 3
    _SYSCALL_DEF _stat, 4
    _SYSCALL_DEF _fstat, 5
    _SYSCALL_DEF _lstat, 6
    _SYSCALL_DEF _poll, 7
    _SYSCALL_DEF _lseek, 8
    _SYSCALL_DEF _mmap, 9
    _SYSCALL_DEF _mprotect, 10
    _SYSCALL_DEF _munmap, 11
    _SYSCALL_DEF _brk, 12
    _SYSCALL_DEF _rt_sigaction, 13
    _SYSCALL_DEF _rt_sigprocmask, 14
    _SYSCALL_DEF _rt_sigreturn, 15
    _SYSCALL_DEF _ioctl, 16
    _SYSCALL_DEF _pread64, 17
    _SYSCALL_DEF _pwrite64, 18
    _SYSCALL_DEF _readv, 19
    _SYSCALL_DEF _writev, 20
    _SYSCALL_DEF _access, 21
    _SYSCALL_DEF _pipe, 22
    _SYSCALL_DEF _select, 23
    _SYSCALL_DEF _sched_yield, 24
    _SYSCALL_DEF _mremap, 25
    _SYSCALL_DEF _msync, 26
    _SYSCALL_DEF _mincore, 27
    _SYSCALL_DEF _madvise, 28
    _SYSCALL_DEF _shmget, 29
    _SYSCALL_DEF _shmat, 30
    _SYSCALL_DEF _shmctl, 31
    _SYSCALL_DEF _dup, 32
    _SYSCALL_DEF _dup2, 33
    _SYSCALL_DEF _pause, 34
    _SYSCALL_DEF _nanosleep, 35
    _SYSCALL_DEF _getitimer, 36
    _SYSCALL_DEF _alarm, 37
    _SYSCALL_DEF _setitimer, 38
    _SYSCALL_DEF _getpid, 39
    _SYSCALL_DEF _sendfile, 40
    _SYSCALL_DEF _socket, 41
    _SYSCALL_DEF _connect, 42
    _SYSCALL_DEF _accept, 43
    _SYSCALL_DEF _sendto, 44
    _SYSCALL_DEF _recvfrom, 45
    _SYSCALL_DEF _sendmsg, 46
    _SYSCALL_DEF _recvmsg, 47
    _SYSCALL_DEF _shutdown, 48
    _SYSCALL_DEF _bind, 49
    _SYSCALL_DEF _listen, 50
    _SYSCALL_DEF _getsockname, 51
    _SYSCALL_DEF _getpeername, 52
    _SYSCALL_DEF _socketpair, 53
    _SYSCALL_DEF _setsockopt, 54
    _SYSCALL_DEF _getsockopt, 55
    _SYSCALL_DEF _clone, 56
    _SYSCALL_DEF _fork, 57
    _SYSCALL_DEF _vfork, 58
    _SYSCALL_DEF _execve, 59
    _SYSCALL_DEF _exit, 60
    _SYSCALL_DEF _wait4, 61
    _SYSCALL_DEF _kill, 62
    _SYSCALL_DEF _uname, 63
    _SYSCALL_DEF _semget, 64
    _SYSCALL_DEF _semop, 65
    _SYSCALL_DEF _semctl, 66
    _SYSCALL_DEF _shmdt, 67
    _SYSCALL_DEF _msgget, 68
    _SYSCALL_DEF _msgsnd, 69
    _SYSCALL_DEF _msgrcv, 70
    _SYSCALL_DEF _msgctl, 71
    _SYSCALL_DEF _fcntl, 72
    _SYSCALL_DEF _flock, 73
    _SYSCALL_DEF _fsync, 74
    _SYSCALL_DEF _fdatasync, 75
    _SYSCALL_DEF _truncate, 76
    _SYSCALL_DEF _ftruncate, 77
    _SYSCALL_DEF _getdents, 78
    _SYSCALL_DEF _getcwd, 79
    _SYSCALL_DEF _chdir, 80
    _SYSCALL_DEF _fchdir, 81
    _SYSCALL_DEF _rename, 82
    _SYSCALL_DEF _mkdir, 83
    _SYSCALL_DEF _rmdir, 84
    _SYSCALL_DEF _creat, 85
    _SYSCALL_DEF _link, 86
    _SYSCALL_DEF _unlink, 87
    _SYSCALL_DEF _symlink, 88
    _SYSCALL_DEF _readlink, 89
    _SYSCALL_DEF _chmod, 90
    _SYSCALL_DEF _fchmod, 91
    _SYSCALL_DEF _chown, 92
    _SYSCALL_DEF _fchown, 93
    _SYSCALL_DEF _lchown, 94
    _SYSCALL_DEF _umask, 95
    _SYSCALL_DEF _gettimeofday, 96
    _SYSCALL_DEF _getrlimit, 97
    _SYSCALL_DEF _getrusage, 98
    _SYSCALL_DEF _sysinfo, 99
    _SYSCALL_DEF _times, 100
    _SYSCALL_DEF _ptrace, 101
    _SYSCALL_DEF _getuid, 102
    _SYSCALL_DEF _syslog, 103
    _SYSCALL_DEF _getgid, 104
    _SYSCALL_DEF _setuid, 105
    _SYSCALL_DEF _setgid, 106
    _SYSCALL_DEF _geteuid, 107
    _SYSCALL_DEF _getegid, 108
    _SYSCALL_DEF _setpgid, 109
    _SYSCALL_DEF _getppid, 110
    _SYSCALL_DEF _getpgrp, 111
    _SYSCALL_DEF _setsid, 112
    _SYSCALL_DEF _setreuid, 113
    _SYSCALL_DEF _setregid, 114
    _SYSCALL_DEF _getgroups, 115
    _SYSCALL_DEF _setgroups, 116
    _SYSCALL_DEF _setresuid, 117
    _SYSCALL_DEF _getresuid, 118
    _SYSCALL_DEF _setresgid, 119
    _SYSCALL_DEF _getresgid, 120
    _SYSCALL_DEF _getpgid, 121
    _SYSCALL_DEF _setfsuid, 122
    _SYSCALL_DEF _setfsgid, 123
    _SYSCALL_DEF _getsid, 124
    _SYSCALL_DEF _capget, 125
    _SYSCALL_DEF _capset, 126
    _SYSCALL_DEF _rt_sigpending, 127
    _SYSCALL_DEF _rt_sigtimedwait, 128
    _SYSCALL_DEF _rt_sigqueueinfo, 129
    _SYSCALL_DEF _rt_sigsuspend, 130
    _SYSCALL_DEF _sigaltstack, 131
    _SYSCALL_DEF _utime, 132
    _SYSCALL_DEF _mknod, 133
    _SYSCALL_DEF _uselib, 134
    _SYSCALL_DEF _personality, 135
    _SYSCALL_DEF _ustat, 136
    _SYSCALL_DEF _statfs, 137
    _SYSCALL_DEF _fstatfs, 138
    _SYSCALL_DEF _sysfs, 139
    _SYSCALL_DEF _getpriority, 140
    _SYSCALL_DEF _setpriority, 141
    _SYSCALL_DEF _sched_setparam, 142
    _SYSCALL_DEF _sched_getparam, 143
    _SYSCALL_DEF _sched_setscheduler, 144
    _SYSCALL_DEF _sched_getscheduler, 145
    _SYSCALL_DEF _sched_get_priority_max, 146
    _SYSCALL_DEF _sched_get_priority_min, 147
    _SYSCALL_DEF _sched_rr_get_interval, 148
    _SYSCALL_DEF _mlock, 149
    _SYSCALL_DEF _munlock, 150
    _SYSCALL_DEF _mlockall, 151
    _SYSCALL_DEF _munlockall, 152
    _SYSCALL_DEF _vhangup, 153
    _SYSCALL_DEF _modify_ldt, 154
    _SYSCALL_DEF _pivot_root, 155
    _SYSCALL_DEF __sysctl, 156
    _SYSCALL_DEF _prctl, 157
    _SYSCALL_DEF _arch_prctl, 158
    _SYSCALL_DEF _adjtimex, 159
    _SYSCALL_DEF _setrlimit, 160
    _SYSCALL_DEF _chroot, 161
    _SYSCALL_DEF _sync, 162
    _SYSCALL_DEF _acct, 163
    _SYSCALL_DEF _settimeofday, 164
    _SYSCALL_DEF _mount, 165
    _SYSCALL_DEF _umount2, 166
    _SYSCALL_DEF _swapon, 167
    _SYSCALL_DEF _swapoff, 168
    _SYSCALL_DEF _reboot, 169
    _SYSCALL_DEF _sethostname, 170
    _SYSCALL_DEF _setdomainname, 171
    _SYSCALL_DEF _iopl, 172
    _SYSCALL_DEF _ioperm, 173
    _SYSCALL_DEF _create_module, 174
    _SYSCALL_DEF _init_module, 175
    _SYSCALL_DEF _delete_module, 176
    _SYSCALL_DEF _get_kernel_syms, 177
    _SYSCALL_DEF _query_module, 178
    _SYSCALL_DEF _quotactl, 179
    _SYSCALL_DEF _nfsservctl, 180
    _SYSCALL_DEF _getpmsg, 181
    _SYSCALL_DEF _putpmsg, 182
    _SYSCALL_DEF _afs_syscall, 183
    _SYSCALL_DEF _tuxcall, 184
    _SYSCALL_DEF _security, 185
    _SYSCALL_DEF _gettid, 186
    _SYSCALL_DEF _readahead, 187
    _SYSCALL_DEF _setxattr, 188
    _SYSCALL_DEF _lsetxattr, 189
    _SYSCALL_DEF _fsetxattr, 190
    _SYSCALL_DEF _getxattr, 191
    _SYSCALL_DEF _lgetxattr, 192
    _SYSCALL_DEF _fgetxattr, 193
    _SYSCALL_DEF _listxattr, 194
    _SYSCALL_DEF _llistxattr, 195
    _SYSCALL_DEF _flistxattr, 196
    _SYSCALL_DEF _removexattr, 197
    _SYSCALL_DEF _lremovexattr, 198
    _SYSCALL_DEF _fremovexattr, 199
    _SYSCALL_DEF _tkill, 200
    _SYSCALL_DEF _time, 201
    _SYSCALL_DEF _futex, 202
    _SYSCALL_DEF _sched_setaffinity, 203
    _SYSCALL_DEF _sched_getaffinity, 204
    _SYSCALL_DEF _set_thread_area, 205
    _SYSCALL_DEF _io_setup, 206
    _SYSCALL_DEF _io_destroy, 207
    _SYSCALL_DEF _io_getevents, 208
    _SYSCALL_DEF _io_submit, 209
    _SYSCALL_DEF _io_cancel, 210
    _SYSCALL_DEF _get_thread_area, 211
    _SYSCALL_DEF _lookup_dcookie, 212
    _SYSCALL_DEF _epoll_create, 213
    _SYSCALL_DEF _epoll_ctl_old, 214
    _SYSCALL_DEF _epoll_wait_old, 215
    _SYSCALL_DEF _remap_file_pages, 216
    _SYSCALL_DEF _getdents64, 217
    _SYSCALL_DEF _set_tid_address, 218
    _SYSCALL_DEF _restart_syscall, 219
    _SYSCALL_DEF _semtimedop, 220
    _SYSCALL_DEF _fadvise64, 221
    _SYSCALL_DEF _timer_create, 222
    _SYSCALL_DEF _timer_settime, 223
    _SYSCALL_DEF _timer_gettime, 224
    _SYSCALL_DEF _timer_getoverrun, 225
    _SYSCALL_DEF _timer_delete, 226
    _SYSCALL_DEF _clock_settime, 227
    _SYSCALL_DEF _clock_gettime, 228
    _SYSCALL_DEF _clock_getres, 229
    _SYSCALL_DEF _clock_nanosleep, 230
    _SYSCALL_DEF _exit_group, 231
    _SYSCALL_DEF _epoll_wait, 232
    _SYSCALL_DEF _epoll_ctl, 233
    _SYSCALL_DEF _tgkill, 234
    _SYSCALL_DEF _utimes, 235
    _SYSCALL_DEF _vserver, 236
    _SYSCALL_DEF _mbind, 237
    _SYSCALL_DEF _set_mempolicy, 238
    _SYSCALL_DEF _get_mempolicy, 239
    _SYSCALL_DEF _mq_open, 240
    _SYSCALL_DEF _mq_unlink, 241
    _SYSCALL_DEF _mq_timedsend, 242
    _SYSCALL_DEF _mq_timedreceive, 243
    _SYSCALL_DEF _mq_notify, 244
    _SYSCALL_DEF _mq_getsetattr, 245
    _SYSCALL_DEF _kexec_load, 246
    _SYSCALL_DEF _waitid, 247
    _SYSCALL_DEF _add_key, 248
    _SYSCALL_DEF _request_key, 249
    _SYSCALL_DEF _keyctl, 250
    _SYSCALL_DEF _ioprio_set, 251
    _SYSCALL_DEF _ioprio_get, 252
    _SYSCALL_DEF _inotify_init, 253
    _SYSCALL_DEF _inotify_add_watch, 254
    _SYSCALL_DEF _inotify_rm_watch, 255
    _SYSCALL_DEF _migrate_pages, 256
    _SYSCALL_DEF _openat, 257
    _SYSCALL_DEF _mkdirat, 258
    _SYSCALL_DEF _mknodat, 259
    _SYSCALL_DEF _fchownat, 260
    _SYSCALL_DEF _futimesat, 261
    _SYSCALL_DEF _newfstatat, 262
    _SYSCALL_DEF _unlinkat, 263
    _SYSCALL_DEF _renameat, 264
    _SYSCALL_DEF _linkat, 265
    _SYSCALL_DEF _symlinkat, 266
    _SYSCALL_DEF _readlinkat, 267
    _SYSCALL_DEF _fchmodat, 268
    _SYSCALL_DEF _faccessat, 269
    _SYSCALL_DEF _pselect6, 270
    _SYSCALL_DEF _ppoll, 271
    _SYSCALL_DEF _unshare, 272
    _SYSCALL_DEF _set_robust_list, 273
    _SYSCALL_DEF _get_robust_list, 274
    _SYSCALL_DEF _splice, 275
    _SYSCALL_DEF _tee, 276
    _SYSCALL_DEF _sync_file_range, 277
    _SYSCALL_DEF _vmsplice, 278
    _SYSCALL_DEF _move_pages, 279
    _SYSCALL_DEF _utimensat, 280
    _SYSCALL_DEF _epoll_pwait, 281
    _SYSCALL_DEF _signalfd, 282
    _SYSCALL_DEF _timerfd_create, 283
    _SYSCALL_DEF _eventfd, 284
    _SYSCALL_DEF _fallocate, 285
    _SYSCALL_DEF _timerfd_settime, 286
    _SYSCALL_DEF _timerfd_gettime, 287
    _SYSCALL_DEF _accept4, 288
    _SYSCALL_DEF _signalfd4, 289
    _SYSCALL_DEF _eventfd2, 290
    _SYSCALL_DEF _epoll_create1, 291
    _SYSCALL_DEF _dup3, 292
    _SYSCALL_DEF _pipe2, 293
    _SYSCALL_DEF _inotify_init1, 294
    _SYSCALL_DEF _preadv, 295
    _SYSCALL_DEF _pwritev, 296
    _SYSCALL_DEF _rt_tgsigqueueinfo, 297
    _SYSCALL_DEF _perf_event_open, 298
    _SYSCALL_DEF _recvmmsg, 299
    _SYSCALL_DEF _fanotify_init, 300
    _SYSCALL_DEF _fanotify_mark, 301
    _SYSCALL_DEF _prlimit64, 302
    _SYSCALL_DEF _name_to_handle_at, 303
    _SYSCALL_DEF _open_by_handle_at, 304
    _SYSCALL_DEF _clock_adjtime, 305
    _SYSCALL_DEF _syncfs, 306
    _SYSCALL_DEF _sendmmsg, 307
    _SYSCALL_DEF _setns, 308
    _SYSCALL_DEF _getcpu, 309
    _SYSCALL_DEF _process_vm_readv, 310
    _SYSCALL_DEF _process_vm_writev, 311
    _SYSCALL_DEF _kcmp, 312
    _SYSCALL_DEF _finit_module, 313
    _SYSCALL_DEF _sched_setattr, 314
    _SYSCALL_DEF _sched_getattr, 315
    _SYSCALL_DEF _renameat2, 316
    _SYSCALL_DEF _seccomp, 317
    _SYSCALL_DEF _getrandom, 318
    _SYSCALL_DEF _memfd_create, 319
    _SYSCALL_DEF _kexec_file_load, 320
    _SYSCALL_DEF _bpf, 321
    _SYSCALL_DEF _execveat, 322
    _SYSCALL_DEF _userfaultfd, 323
    _SYSCALL_DEF _membarrier, 324
    _SYSCALL_DEF _mlock2, 325
    _SYSCALL_DEF _copy_file_range, 326
    _SYSCALL_DEF _preadv2, 327
    _SYSCALL_DEF _pwritev2, 328
    _SYSCALL_DEF _pkey_mprotect, 329
    _SYSCALL_DEF _pkey_alloc, 330
    _SYSCALL_DEF _pkey_free, 331
    _SYSCALL_DEF _statx, 332
    _SYSCALL_DEF _io_pgetevents, 333
    _SYSCALL_DEF _rseq, 334

endif;    /*, _ASM_X86_UNISTD_64_H, */