You seem to have a misunderstanding about how software is compiled. Linux is essentially a giant piece of software written in the C programming language.
One of the primary benefits of writing software in a higher level language than assembly is that it allows for software to be written independently from the CPU's architecture. The same code (written in C) can be compiled for multiple architecture types.
If you type gcc
into your RPi's terminal, you'll see it's installed there. To see the compiler in action, use the "hello world" tutorial below and compile it with the -S
flag on both an x86 PC and the RPi. If you compare the two, you'll see the assembly output is significantly different, even though both outputs were produced by the same C code. The Linux OS operates in the same manner.
Sample C Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
printf("Hello, World!\n");
exit(EXIT_SUCCESS);
}
gcc -S output on a Xeon (x86-64):
.file "hello.c"
.section .rodata
.LC0:
.string "Hello, World!"
.text
.globl main
.type main, @function
main:
.LFB2:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl %edi, -4(%rbp)
movq %rsi, -16(%rbp)
movl $.LC0, %edi
call puts
movl $0, %edi
call exit
.cfi_endproc
.LFE2:
.size main, .-main
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"
.section .note.GNU-stack,"",@progbits
gcc -S output on a Raspberry Pi 2 (Cortex-A7):
.arch armv6
.eabi_attribute 27, 3
.eabi_attribute 28, 1
.fpu vfp
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 2
.eabi_attribute 30, 6
.eabi_attribute 34, 1
.eabi_attribute 18, 4
.file "hello.c"
.section .rodata
.align 2
.LC0:
.ascii "Hello, World!\000"
.text
.align 2
.global main
.type main, %function
main:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, uses_anonymous_args = 0
stmfd sp!, {fp, lr}
add fp, sp, #4
sub sp, sp, #8
str r0, [fp, #-8]
str r1, [fp, #-12]
ldr r0, .L2
bl puts
mov r0, #0
bl exit
.L3:
.align 2
.L2:
.word .LC0
.size main, .-main
.ident "GCC: (Raspbian 4.9.2-10) 4.9.2"
.section .note.GNU-stack,"",%progbits