Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuehhua/gcc-compiler
A demo of gcc compilation collection
https://github.com/yuehhua/gcc-compiler
Last synced: 12 days ago
JSON representation
A demo of gcc compilation collection
- Host: GitHub
- URL: https://github.com/yuehhua/gcc-compiler
- Owner: yuehhua
- Created: 2020-03-04T16:23:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-04T16:28:49.000Z (almost 5 years ago)
- Last Synced: 2023-02-27T00:21:46.431Z (almost 2 years ago)
- Language: C
- Size: 1000 Bytes
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gcc-compiler
A demo of gcc compilation collection## Compile process
### Preprocess
```
gcc -E hello.c -o hello.i
```### Compile
```
gcc -S hello.i -o hello.s -O2
```### Assemble
```
as hello.s -o hello.o
```### Disassemble object file to see machine code and assembly
```
objdump -d hello.o
```### Show header, body information of object file
```
objdump -x hello.o
```### Dynamic linker/loader
```
ld hello.o -o hello
```### Run
```
./hello
```### Check content of executable file
```
readelf -h hello
```### Directly compile to executable file
```
gcc hello.c -o hello
```### Check file format
```
file hello
```
---## Compile sum
### Compile and assemble
```
gcc -O2 -c sum.c -o sum.o
```### Static link
```
ar rcs libsum.a sum.o
```### Compile main with static library
```
cc main.c libsum.a -o main
```