[PATCH] D13141: [ELF2] Fix assembler so that it maches description

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 10:30:32 PDT 2015


davide created this revision.
davide added a reviewer: rafael.
davide added a subscriber: llvm-commits.
davide set the repository for this revision to rL LLVM.

I tried to run basic.s on my machine and noticed it crashes. I tracked with truss(1) and realized it's actually trying to execute the wrong system call.

% truss ./basic
Segmentation fault (core dumped)
davide at rabbit1:/exps/llvm-lld/tools/lld/test/elf2 % objdump
davide at rabbit1:/exps/llvm-lld/tools/lld/test/elf2 % truss ./basic
umask(0x2a,0x0,0x0,0x0,0x0,0x0)                  = 18 (0x12)
SIGNAL 11 (SIGSEGV)
process exit, rval = 0

POSIX doesn't know about syscall numbers (or in general system calls), so this code is inherently unportable In reality, it's fairly unlikely somebody assigns '1' to something different than exit() so we should be able to run this code on several UNIXes even if it was written with Linux as target.

Repository:
  rL LLVM

http://reviews.llvm.org/D13141

Files:
  basic.s

Index: basic.s
===================================================================
--- basic.s
+++ basic.s
@@ -7,7 +7,7 @@
 # exits with return code 42 on linux
 .globl _start;
 _start:
-  mov $60, %rax
+  mov $1,  %rax
   mov $42, %rdi
   syscall



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13141.35650.patch
Type: text/x-patch
Size: 249 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150924/21a94e3e/attachment.bin>


More information about the llvm-commits mailing list