t4 1 How Programming Works
t4 1 How Programming Works
or:
$ as myProg.s -o myProg.o
$ gcc myProg.o -o myProg
Note:
crt1.o: Newer style of the initial runtime code. Contains the _start symbol which sets up
the env with argc/argv/libc _init/libc _fini before jumping to the libc main. glibc
calls this file 'start.s'.
crti.o: Defines the function prolog; _init in the .init section and _fini in the .fini section.
glibc calls this 'initfini.c'.
crtn.o: Defines the function epilog. glibc calls this 'initfini.c'.
https://wiki.osdev.org/Creating_a_C_Library
C Programming Review
Compiling - The modified source code is compiled into binary object code. This code is
not yet executable.
Linking - The object code is combined with required supporting code to make an
executable program. This step typically involves adding in any libraries that are required.
C Programming Review
General programming intro:
.data
#include <stdio.h>
string:
void main()
.asciz "\nHello World!\n"
{
.text
char *hi = “Hello world!”;
.global main
printf(“%s\n”,hi);
.extern printf
}
main:
push {ip, lr}
ldr r0, =string
bl printf
pop {ip, pc}
C Programming Review
How Makefile work?
https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html#Automatic-Variables
Who compile what?
What happened when we call extern?
an application binary interface (ABI) is an interface between two binary program modules; often, one of
these modules is a library (or operating system facility), and the other is a program that is being run by a
user.
An ABI defines how data structures or computational routines are accessed in machine code (a low-level,
hardware-dependent format); in contrast, an API defines this access in source code (a relatively high-level,
hardware-independent, often human-readable format).
An embedded-application binary interface (EABI) specifies standard conventions for file formats, data types,
register usage, stack frame organization, and function parameter passing of an embedded software
program, for use in an embedded system.
ARM provides its compiler (and linker) framework for their user
GNU (community) also has its own compiler/linker
Cross-compilation
Example for Interfacing
See:
http://www.science.smith.edu/dftwiki/index.php/Tutorial:_Assembly_Language_with_the_Raspberry_Pi
More into ISA
In the assembly version, we’ve seen:
How sections are made
How memory are referred (as labels)
What registers are used
What addressing modes are used
Condition and branching instruction
How ARM Procedure Call Standards are used (related to ABI)