0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

概要

paiza.ioでaarch64アセンブラやってみる。
bit数を確認する。
仕掛けは、rustでシェルコマンドを実行する。

サンプルコード


use std::fs;
use std::io::{Write, BufWriter};
use std::process::Command;

fn main() {
	let b = "
#include <stdio.h>
 
int main(int argc, char **argv, char **evnp) {
#ifdef __LP64__
    printf(\"64bit >> \");
#else
    printf(\"32bit >> \");
#endif
    printf(\"Hello world.\");
    return 0;
}
";
    let mut f = BufWriter::new(fs::File::create("hello.c").unwrap()); 
    f.write(b.as_bytes()).unwrap();
    f.flush();

    let output0 = Command::new("gcc").arg("hello.c").output().expect("failed to execute process");
    let hello0 = output0.stderr;
    println!("{}", std::str::from_utf8(&hello0).unwrap());
        
    let output = Command::new("./a.out").output().expect("failed to execute process");
    let hello = output.stdout;
    println!("{}", std::str::from_utf8(&hello).unwrap());
}

    
    

実行結果


64bit >> Hello world.

成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?