Skip to content

Commit

Permalink
nasm: Use different test sources for x86 and x86_64
Browse files Browse the repository at this point in the history
The x86 test files might not work on x86_64 Linux in certain cases,
for example if the kernel is configured without support for x86
executables (which also gets rid of the old system call interface).

Bug: https://bugs.gentoo.org/936911
(cherry picked from commit 9501228)
  • Loading branch information
qookei authored and eli-schwartz committed Sep 20, 2024
1 parent e409a55 commit af9658a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
File renamed without changes.
18 changes: 18 additions & 0 deletions test cases/nasm/1 configure file/hello-x86_64.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%include "config.asm"

section .data
msg: db "Hello World", 10
len: equ $ - msg

section .text
global main
main:
mov eax, 1 ; sys_write
mov edi, 1 ; fd = STDOUT_FILENO
mov rsi, msg ; buf = msg
mov rdx, len ; count = len
syscall

mov eax, 60 ; sys_exit
mov edi, HELLO ; exit code
syscall
2 changes: 1 addition & 1 deletion test cases/nasm/1 configure file/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ config_file = configure_file(
cc = meson.get_compiler('c')
link_args = cc.get_supported_link_arguments(['-no-pie'])

exe = executable('hello', asm_gen.process('hello.asm'),
exe = executable('hello', asm_gen.process('hello-' + host_machine.cpu_family() + '.asm'),
link_args: link_args,
)

Expand Down
File renamed without changes.
22 changes: 22 additions & 0 deletions test cases/nasm/2 asm language/hello-x86_64.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%include "config.asm"

%ifdef FOO
%define RETVAL HELLO
%endif

section .data
msg: db "Hello World", 10
len: equ $ - msg

section .text
global main
main:
mov eax, 1 ; sys_write
mov edi, 1 ; fd = STDOUT_FILENO
mov rsi, msg ; buf = msg
mov rdx, len ; count = len
syscall

mov eax, 60 ; sys_exit
mov edi, RETVAL ; exit code
syscall
4 changes: 2 additions & 2 deletions test cases/nasm/2 asm language/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ config_file = configure_file(
cc = meson.get_compiler('c')
link_args = cc.get_supported_link_arguments(['-no-pie'])

exe = executable('hello', 'hello.asm',
exe = executable('hello', 'hello-' + host_machine.cpu_family() + '.asm',
nasm_args: '-DFOO',
link_args: link_args,
)
Expand All @@ -55,7 +55,7 @@ test('hello', exe)
#Test whether pthread dependency gets filtered out
threads = dependency('threads')

exe2 = executable('hello_w_threads', 'hello.asm',
exe2 = executable('hello_w_threads', 'hello-' + host_machine.cpu_family() + '.asm',
config_file,
nasm_args: '-DFOO',
link_args: link_args,
Expand Down

0 comments on commit af9658a

Please sign in to comment.