Author Topic: 1st Ever ARM64 Assembly Language Quine?  (Read 1595 times)

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 68
  • Country: ph
    • Webpage
1st Ever ARM64 Assembly Language Quine?
« on: July 03, 2023, 12:07:50 AM »
I don't even see a legit printf example on ARM64 Assembly Language floating around the Internetz.

enjoy as usual and probably NASM will suddenly have ARM64/32 support..

Code: [Select]
/*
;
; aarch64-linux-gnu-as printfarm64.asm -o printfarm64.o
; aarch64-linux-gnu-ld -lc /usr/aarch64-linux-gnu/lib/libc.so.6 -o printfarm64 printfarm64.o
;
;  ***     copy the contents of /usr/aarch64-linux-gnu/lib/ to /lib/
;
;  ****    dpkg -L libc6-arm64-cross | grep -i ld-linux-aarch64.so.1
;          /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1
;
;  *****   dpkg -L libc6 | grep -i libc.so.6
;          /usr/aarch64-linux-gnu/lib/libc.so.6
;
;;
;~ House Of Guillermo [GIMO]
;~~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf], NYC 7/1/2023 5:46 PM EDT - 7/2/2023 5:11 PM EDT
;
*/
.section .text
.global _start
.extern printf,putchar,exit
_start:
LDR X0,=msg
BL printf
MOV X0,34
BL putchar
LDR X0,=msg
BL printf
MOV X0,34
BL putchar
MOV X0,0
BL exit
.section .data
msg:.asciz "/*
;
; aarch64-linux-gnu-as printfarm64.asm -o printfarm64.o
; aarch64-linux-gnu-ld -lc /usr/aarch64-linux-gnu/lib/libc.so.6 -o printfarm64 printfarm64.o
;
;  ***     copy the contents of /usr/aarch64-linux-gnu/lib/ to /lib/
;
;  ****    dpkg -L libc6-arm64-cross | grep -i ld-linux-aarch64.so.1
;          /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1
;
;  *****   dpkg -L libc6 | grep -i libc.so.6
;          /usr/aarch64-linux-gnu/lib/libc.so.6
;
;;
;~ House Of Guillermo [GIMO]
;~~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf], NYC 7/1/2023 5:46 PM EDT - 7/2/2023 5:11 PM EDT
;
*/
.section .text
.global _start
.extern printf,putchar,exit
_start:
LDR X0,=msg
BL printf
MOV X0,34
BL putchar
LDR X0,=msg
BL printf
MOV X0,34
BL putchar
MOV X0,0
BL exit
.section .data
msg:.asciz "

it runs in latest Ubuntu (Linux on Windows Subsystem) with the arm64 cross compilers and libc6 (arm64). there's a bug tho after building an ARM64 executable - it assumes that it runs in an ARM64 Ubuntu Distro and hardcodely references a file that is not there. so you have to move files from folder to folder. the said missing file when ARM64 executables are run are there, installed.

this has no errors if it can be roundtripped .. 1.) as/ld printfarm64.asm 2.) ./printfarm64 > arm64xx2.asm 3.) go to 1 replacing printfarm64.asm with arm64xx2.asm 4.) ./arm64xx2 5.) and so on..

assembling the source will generate warnings that can be not taken seriously coz the processes are alright..

btw, the linux arm64 architecture is via qemu and the website of Azeria helped me to setup my ARM dev box...

https://azeria-labs.com/arm-on-x86-qemu-user/


Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 68
  • Country: ph
    • Webpage
Re: 1st Ever ARM64 Assembly Language Quine?
« Reply #1 on: July 04, 2023, 06:07:26 AM »
1st Ever ARM32 Quine??

Code: [Select]

/*
;
;  arm-linux-gnueabihf-as 32Ge.asm -o 32Ge.o
;  arm-linux-gnueabihf-gcc -static -o 32Ge 32Ge.o
;
;~~ arm32quine v1.0-044
;
;~ House Of Guillermo [GIMO]
;~~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf], NYC 7/3/2023 1:40 AM
*/
.section .text
.global main
.extern printf,putchar,exit
main:
LDR R0,=msg
BL printf
MOV R0,#34
BL putchar
LDR R0,=msg
BL printf
MOV R0,#34
BL putchar
MOV R0,#0
BL exit
.section .data
msg:.asciz "/*
;
;  arm-linux-gnueabihf-as 32Ge.asm -o 32Ge.o
;  arm-linux-gnueabihf-gcc -static -o 32Ge 32Ge.o
;
;~~ arm32quine v1.0-044
;
;~ House Of Guillermo [GIMO]
;~~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf], NYC 7/3/2023 1:40 AM
*/
.section .text
.global main
.extern printf,putchar,exit
main:
LDR R0,=msg
BL printf
MOV R0,#34
BL putchar
LDR R0,=msg
BL printf
MOV R0,#34
BL putchar
MOV R0,#0
BL exit
.section .data
msg:.asciz "


Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 68
  • Country: ph
    • Webpage
Re: 1st Ever ARM64 Assembly Language Quine?
« Reply #2 on: July 05, 2023, 11:36:10 PM »
the first source code is a dynamic executable made under Ubuntu 22.04.2 LTS running in Linux on Windows Subsystem so you gotta make your /distro r/w so you can copy/overwrite files on /lib/ coz it is hardcoded that the executable made will read its appropriate libraries there..

the 2nd executable is static coz dynamically linked ARM32 object file will search for a file that doesn't exist so you gotta do some lazy meme gcc linking..

and then the source code below is ARM64 but meme gcc-ed to be statically created under Ubuntu 22.04.2 LTS in Hyper-V.

Code: [Select]
/*
;
; aarch64-linux-gnu-as printfarm64.asm -o printfarm64.o
; aarch64-linux-gnu-gcc -static -o printfarm64 printfarm64.o
;
;;
;~ House Of Guillermo [GIMO]
;~~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf], NYC 7/1/2023 5:46 PM EDT - 7/2/2023 5:11 PM EDT
;
*/
.section .text
.global main
.extern printf,putchar,exit
main:
LDR X0,=msg
BL printf
MOV X0,34
BL putchar
LDR X0,=msg
BL printf
MOV X0,34
BL putchar
MOV X0,0
BL exit
.section .data
msg:.asciz "/*
;
; aarch64-linux-gnu-as printfarm64.asm -o printfarm64.o
; aarch64-linux-gnu-gcc -static -o printfarm64 printfarm64.o
;
;;
;~ House Of Guillermo [GIMO]
;~~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf], NYC 7/1/2023 5:46 PM EDT - 7/2/2023 5:11 PM EDT
;
*/
.section .text
.global main
.extern printf,putchar,exit
main:
LDR X0,=msg
BL printf
MOV X0,34
BL putchar
LDR X0,=msg
BL printf
MOV X0,34
BL putchar
MOV X0,0
BL exit
.section .data
msg:.asciz "

and the ARM32 was made in Ubuntu 16.04 LTS in Hyper-V.

like everything was seamless and it was even ridiculously funny.

like ARM64 was released in 2011. don't tell me no one made this kinda shizzzz during the 12 years that ARM32/ARM64 existed.

and yes, libc6 functions are legit to use coz that's how you write Win32/Win64 programs - by using the WINAPI libraries. and mind you, The C Standard Library is wayyyyyyyyyyy older than Win32s..

and if you insist that it's not valid and i must use syscall, like the f***, that's how the DOS programs were written.

and how is the established protocol of using ml64.exe currently? you mix it with c++ and you cannot inline it.

and these three source codes are mixed with c stdlib functions and ARM32 & ARM64 assembly language programming.

and it's only 10 lines of ARM coded mnemonic. the rest are strings and comments (lelz)..

and just took 3 days from the time that i set on gathering my resources and finally triple building it...

2023 - 2011?
« Last Edit: July 05, 2023, 11:42:29 PM by alCoPaUL »