From 54a0b510357bdf9cde5dfb6a87c574324fc7afd6 Mon Sep 17 00:00:00 2001 From: Adam Nuridov Date: Fri, 29 Aug 2014 10:17:41 +0200 Subject: [PATCH] modified: ANSWERS.md new file: Makefile new file: hello.c new file: hello.s new file: l1.h new file: main.c new file: main.map new file: test.c new file: test2.c --- ANSWERS.md | 109 +++++++++----- Makefile | 2 + hello.c | 13 ++ hello.s | 46 ++++++ l1.h | 20 +++ main.c | 21 +++ main.map | 432 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test.c | 11 ++ test2.c | 12 ++ 9 files changed, 628 insertions(+), 38 deletions(-) create mode 100644 Makefile create mode 100644 hello.c create mode 100644 hello.s create mode 100644 l1.h create mode 100644 main.c create mode 100644 main.map create mode 100644 test.c create mode 100644 test2.c diff --git a/ANSWERS.md b/ANSWERS.md index 9e5261a..104a25b 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -19,7 +19,7 @@ Please use [markdown](https://help.github.com/articles/markdown-basics) formatin Make another directory inside the `unixstuff` directory called `backups` -**Answer:** *YOUR ANSWER HERE* +**Answer:** 'cd unixstuff' 'mkdir backups' ###Exercise 1b @@ -27,31 +27,36 @@ Use the commands `cd`, `ls` and `pwd` to explore the file system. (Remember, if you get lost, type `cd` by itself to return to your home-directory) -**Answer:** *YOUR ANSWER HERE* +**Answer:** 'pwd' 'ls -a' 'cd Documents/opsys/labs/lab1' 'cd' ###Exercise 2a Create a backup of your `science.txt` file by copying it to a file called `science.bak` -**Answer:** *YOUR ANSWER HERE* +**Answer:** 'cp science.txt science.bak' ###Exercise 2b Create a directory called `tempstuff` using `mkdir`, then remove it using the `rmdir` command. -**Answer:** *YOUR ANSWER HERE* +**Answer:** 'mkdir tempstuff' 'rmdir tempstuff' ###Exercise 3a Using the above method, create another file called `list2` containing the following fruit: orange, plum, mango, grapefruit. Read the contents of `list2`. -**Answer:** *YOUR ANSWER HERE* +**Answer:** 'cat > list2' +'orange +plum +mango +grapefruit' +'cat list2' ###Exercise 3b Using pipes, display all lines of `list1` and `list2` containing the letter 'p', and sort the result. -**Answer:** *YOUR ANSWER HERE* +**Answer:** 'cat list1 list2 | grep p | sort' ###Exercise 5a @@ -59,77 +64,84 @@ Try changing access permissions on the file `science.txt` and on the directory ` Use `ls -l` to check that the permissions have changed. -**Answer:** *YOUR ANSWER HERE* +**Answer:** 'chmod 777 science.txt' 'chmod 777 backups' ##Shell questions 1. What option with the command `rm` is required to remove a directory? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'rm -r dirname' 1. What is the command used to display the manual pages for any command? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'man command' 1. What command will show the first 5 lines of an input file? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'head -5 filename.txt' 1. What command can be used to rename a file? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'mv oldfilename.txt newfilename.txt' 1. What option can we given to `ls` to show the hidden files? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'ls -a' 1. What will the command `cat -n file` do? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** Gives a number to all output lines in the file 1. What will the command `echo -n hello` do? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** Outputs hello, but with no newline after it 1. What command will display s list of the users who currently logged in in the system? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'who' 1. How do you change password on your account? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'sudo passwd USER' 1. How can you list a file in reverse order? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'tac FILENAME' 1. What does the `less` command do? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** display a file with one page at a time 1. With `less` how do you navigate? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** spacebar - next page 1. What command will display the running processes of the current user? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'ps' 1. What command can be used to find the process(es) consuming the most CPU? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'ps -aux | head -2' ##vi questions 1. How do we save a file in `vi` and continue working? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** ":w" 1. What command/key is used to start entering text? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'i' 1. What are the different modes the editor can be in? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** Insert, commando' 1. What command can be used to place the cursor at the beginning of line 4? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** ':4' 1. What will `dd` command do (in command-mode)? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** Deletes the line that the cursor is in 1. How do you undo the most recent changes? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'u' in commando-mode 1. How do you move back one word? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'b' in commando-mode ##The C Language and Make tool Questions 1. How do you use `gcc` to only produce the `.o` file? What is the difference between generating only the `.o` file, and building the `hello` executable done in the previous compilation above? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'gcc -c filename.c -o filename.o' The file can be used to build an exe file later by combining several object files together. The debug info is stored in the object file. 1. Give the command for compiling with `debug` enabled instead of normal compilation for the two examples shown in Listing 2 and Listing 3. Explain how to turn debugging on/off for the two cases. - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** gcc -g filename.c -o filename' 1. Give a brief pros and cons discussion for the two methods to add debug code shown in Listing 2 and Listing 3. - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** Listing 2 only includes debug if it is defined when compiling the program, Listing 3 always includes debug, thus having unnecassery code(bigger exe file). 1. Provide the command for generating the *map* file. Which of the `gcc` tools is responsible for producing a *map* file? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'gcc -Wl,-Map=main.map test.c' Linker is responsible for producing a map file. 1. What is the content of each of the sections in a *map* file. Explain briefly. - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** Discarded input sections, Memory configuration, Linker script and memory map. .text has machine instructions that defines the program. Under .text we have .initN that is used as startup code up till main() and .finiN that is used to define the code that is used after main(). .bss includes non-initialized rw global or static variables or values that are initialized as null. .data has rw static data that are created in the code. .rodata has constant read-only data. 1. Rewrite `hello.c` to produce entries in the *map* file for `.data`, `.bss`, and `.rodata`. Hint: This can be done by adding one variable for each type to the file. - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'int datavariable = 11; +int bss; +static const float rodatavariable = 13.37f; 1. Add the following function to `hello.c`: `double multiply(double x1, double x2)`, which returns `x1*x2`. Use `gcc` to generate an assembly code listing for the program, and examine the assembly code. What assembly instructions are used to do this? Repeat this task, but now replace `double` with `float`. Explain! - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** Double has more bits. When it is double, assembly code uses: 'movsd/mulsd', while when it is float, 'movss/mulss' is used. 1. How does `make` know if a file must be recompiled? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** It recompiles a file because its conservative and assumes that any change in the header file requires recompilation of all dependent files. Newer timestamps will also make it recompile. 1. Provide a `make` command to use a file named `mymakefile` instead of the default `makefile`. - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** 'make -f mymakefile' 1. How do you implement an *include guard*, and why is it needed? - - **Answer:** *YOUR ANSWER HERE* + - **Answer:** '#ifndef RANDOM_M +#define RANDOM_M +. +. +. +#endif' It is needed because it guards from compilation error when the structure type is defined twice. ##Library Task @@ -137,10 +149,31 @@ Insert your code between the brackets `{}`: void main( int argc, char *argv[] ) { + int antall; + sscanf(argv[1], "%d", &antall); + double table[antall]; + int i; + for (i = 0; i < antall; i++) + { + table[i] = rand() % 100 + 1; + printf("%.2f\n", table[i]); + } + double sum = tab_sort_sum(table, antall); + printf("Sum is %1f\n" sum); } double tab_sort_sum( double *tab, int tab_size ) { + qsort(table, table_size, sizeof(double), comp); + double sum; + int i; + printf("sorted:\n"); + for (i = 0; i < tab_size; i++) + { + printf("%.2f\n", tab[i]); + sum += tab[i]; + } + return sum; } diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e9c4895 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +main: main.c l1.h + gcc main.c -o main diff --git a/hello.c b/hello.c new file mode 100644 index 0000000..8994f10 --- /dev/null +++ b/hello.c @@ -0,0 +1,13 @@ +#include + +int main(void) +{ + printf("Hello, world!\n"); + return 0; +} + + +float multiply(float x1, float x2) +{ + return x1*x2; +} diff --git a/hello.s b/hello.s new file mode 100644 index 0000000..9239716 --- /dev/null +++ b/hello.s @@ -0,0 +1,46 @@ + .file "hello.c" + .section .rodata +.LC0: + .string "Hello, world!" + .text +.globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + movl $.LC0, %edi + call puts + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main +.globl multiply + .type multiply, @function +multiply: +.LFB1: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + movss %xmm0, -4(%rbp) + movss %xmm1, -8(%rbp) + movss -4(%rbp), %xmm0 + mulss -8(%rbp), %xmm0 + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE1: + .size multiply, .-multiply + .ident "GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-4)" + .section .note.GNU-stack,"",@progbits diff --git a/l1.h b/l1.h new file mode 100644 index 0000000..70890b0 --- /dev/null +++ b/l1.h @@ -0,0 +1,20 @@ +#include +#include + +int comp(const void * a, const void * b) { + return ( *(double*)a - *(double*)b ); +} + +double tab_sort_sum( double *tab, int tab_size ) +{ + qsort(tab, tab_size, sizeof(double), comp); + double sum; + int i; + printf("sorted:\n"); + for (i = 0; i < tab_size; i++) + { + printf("%.2f\n", tab[i]); + sum += tab[i]; + } + return sum; +} diff --git a/main.c b/main.c new file mode 100644 index 0000000..1042611 --- /dev/null +++ b/main.c @@ -0,0 +1,21 @@ +#include +#include +#include "l1.h" +double tab_sort_sum(double *, int); + + +void main( int argc, char *argv[] ) +{ + int antall; + sscanf(argv[1], "%d", &antall); + double table[antall]; + int i; + for (i = 0; i < antall; i++) + { + table[i] = rand() % 100 + 1; + printf("%.2f\n", table[i]); + } + double sum = tab_sort_sum(table, antall); + printf("Sum is %1f\n", sum); +} + diff --git a/main.map b/main.map new file mode 100644 index 0000000..93b9b98 --- /dev/null +++ b/main.map @@ -0,0 +1,432 @@ +Archive member included because of file (symbol) + +/usr/lib64/libc_nonshared.a(elf-init.oS) + /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o (__libc_csu_fini) + +Discarded input sections + + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + .note.GNU-stack + 0x0000000000000000 0x0 /tmp/ccHMG0n5.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib64/libc_nonshared.a(elf-init.oS) + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o + +Memory Configuration + +Name Origin Length Attributes +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o +LOAD /tmp/ccHMG0n5.o +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc.a +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libc.so +START GROUP +LOAD /lib64/libc.so.6 +LOAD /usr/lib64/libc_nonshared.a +LOAD /lib64/ld-linux-x86-64.so.2 +END GROUP +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc.a +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o +LOAD /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o + 0x0000000000400000 PROVIDE (__executable_start, 0x400000) + 0x0000000000400200 . = (0x400000 + SIZEOF_HEADERS) + +.interp 0x0000000000400200 0x1c + *(.interp) + .interp 0x0000000000400200 0x1c /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.note.ABI-tag 0x000000000040021c 0x20 + .note.ABI-tag 0x000000000040021c 0x20 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.note.gnu.build-id + 0x000000000040023c 0x24 + *(.note.gnu.build-id) + .note.gnu.build-id + 0x000000000040023c 0x24 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.hash + *(.hash) + +.gnu.hash 0x0000000000400260 0x1c + *(.gnu.hash) + .gnu.hash 0x0000000000400260 0x1c /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.dynsym 0x0000000000400280 0x60 + *(.dynsym) + .dynsym 0x0000000000400280 0x60 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.dynstr 0x00000000004002e0 0x3d + *(.dynstr) + .dynstr 0x00000000004002e0 0x3d /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.gnu.version 0x000000000040031e 0x8 + *(.gnu.version) + .gnu.version 0x000000000040031e 0x8 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.gnu.version_d 0x0000000000400328 0x0 load address 0x0000000000400326 + *(.gnu.version_d) + .gnu.version_d + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.gnu.version_r 0x0000000000400328 0x20 + *(.gnu.version_r) + .gnu.version_r + 0x0000000000400328 0x20 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.rela.dyn 0x0000000000400348 0x18 + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + .rela.text 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + .rela.got 0x0000000000400348 0x18 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + *(.rela.sharable_data .rela.sharable_data.* .rela.gnu.linkonce.shrd.*) + *(.rela.sharable_bss .rela.sharable_bss.* .rela.gnu.linkonce.shrb.*) + .rela.sharable_bss + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + .rela.bss 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) + *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) + *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) + *(.rela.ifunc) + +.rela.plt 0x0000000000400360 0x30 + *(.rela.plt) + .rela.plt 0x0000000000400360 0x30 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x0000000000400390 PROVIDE (__rela_iplt_start, .) + *(.rela.iplt) + .rela.iplt 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x0000000000400390 PROVIDE (__rela_iplt_end, .) + +.init 0x0000000000400390 0x18 + *(.init) + .init 0x0000000000400390 0x9 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o + 0x0000000000400390 _init + .init 0x0000000000400399 0x5 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + .init 0x000000000040039e 0x5 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + .init 0x00000000004003a3 0x5 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o + +.plt 0x00000000004003a8 0x30 + *(.plt) + .plt 0x00000000004003a8 0x30 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x00000000004003b8 puts@@GLIBC_2.2.5 + 0x00000000004003c8 __libc_start_main@@GLIBC_2.2.5 + *(.iplt) + .iplt 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.text 0x00000000004003e0 0x1d8 + *(.text.unlikely .text.*_unlikely) + *(.text .stub .text.* .gnu.linkonce.t.*) + .text 0x00000000004003e0 0x2c /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x00000000004003e0 _start + .text 0x000000000040040c 0x17 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o + *fill* 0x0000000000400423 0xd 90909090 + .text 0x0000000000400430 0x92 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + *fill* 0x00000000004004c2 0x2 90909090 + .text 0x00000000004004c4 0x15 /tmp/ccHMG0n5.o + 0x00000000004004c4 main + *fill* 0x00000000004004d9 0x7 90909090 + .text 0x00000000004004e0 0x99 /usr/lib64/libc_nonshared.a(elf-init.oS) + 0x00000000004004e0 __libc_csu_fini + 0x00000000004004f0 __libc_csu_init + *fill* 0x0000000000400579 0x7 90909090 + .text 0x0000000000400580 0x36 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + *fill* 0x00000000004005b6 0x2 90909090 + .text 0x00000000004005b8 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o + *(.gnu.warning) + +.fini 0x00000000004005b8 0xe + *(.fini) + .fini 0x00000000004005b8 0x4 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o + 0x00000000004005b8 _fini + .fini 0x00000000004005bc 0x5 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + .fini 0x00000000004005c1 0x5 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o + 0x00000000004005c6 PROVIDE (__etext, .) + 0x00000000004005c6 PROVIDE (_etext, .) + 0x00000000004005c6 PROVIDE (etext, .) + +.rodata 0x00000000004005c8 0x1e + *(.rodata .rodata.* .gnu.linkonce.r.*) + .rodata.cst4 0x00000000004005c8 0x4 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x00000000004005c8 _IO_stdin_used + *fill* 0x00000000004005cc 0x4 00 + .rodata 0x00000000004005d0 0x8 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + 0x00000000004005d0 __dso_handle + .rodata 0x00000000004005d8 0xe /tmp/ccHMG0n5.o + +.rodata1 + *(.rodata1) + +.eh_frame_hdr 0x00000000004005e8 0x24 + *(.eh_frame_hdr) + .eh_frame_hdr 0x00000000004005e8 0x24 /tmp/ccHMG0n5.o + +.eh_frame 0x0000000000400610 0x7c + *(.eh_frame) + .eh_frame 0x0000000000400610 0x38 /tmp/ccHMG0n5.o + .eh_frame 0x0000000000400648 0x40 /usr/lib64/libc_nonshared.a(elf-init.oS) + 0x58 (size before relaxing) + .eh_frame 0x0000000000400688 0x4 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + +.gcc_except_table + *(.gcc_except_table .gcc_except_table.*) + 0x000000000040068c . = (ALIGN (0x200000) - ((0x200000 - .) & 0x1fffff)) + 0x000000000060068c . = (0x200000 DATA_SEGMENT_ALIGN 0x1000) + +.eh_frame + *(.eh_frame) + +.gcc_except_table + *(.gcc_except_table .gcc_except_table.*) + +.tdata + *(.tdata .tdata.* .gnu.linkonce.td.*) + +.tbss + *(.tbss .tbss.* .gnu.linkonce.tb.*) + *(.tcommon) + +.preinit_array 0x000000000060068c 0x0 + 0x000000000060068c PROVIDE (__preinit_array_start, .) + *(.preinit_array) + 0x000000000060068c PROVIDE (__preinit_array_end, .) + +.init_array 0x000000000060068c 0x0 + 0x000000000060068c PROVIDE (__init_array_start, .) + *(SORT(.init_array.*)) + *(.init_array) + 0x000000000060068c PROVIDE (__init_array_end, .) + +.fini_array 0x000000000060068c 0x0 + 0x000000000060068c PROVIDE (__fini_array_start, .) + *(.fini_array) + *(SORT(.fini_array.*)) + 0x000000000060068c PROVIDE (__fini_array_end, .) + +.ctors 0x0000000000600690 0x10 + *crtbegin.o(.ctors) + .ctors 0x0000000000600690 0x8 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + .ctors 0x0000000000600698 0x8 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + +.dtors 0x00000000006006a0 0x10 + *crtbegin.o(.dtors) + .dtors 0x00000000006006a0 0x8 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + .dtors 0x00000000006006a8 0x8 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + 0x00000000006006a8 __DTOR_END__ + +.jcr 0x00000000006006b0 0x8 + *(.jcr) + .jcr 0x00000000006006b0 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + .jcr 0x00000000006006b0 0x8 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + +.data.rel.ro + *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) + *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) + +.dynamic 0x00000000006006b8 0x190 + *(.dynamic) + .dynamic 0x00000000006006b8 0x190 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x00000000006006b8 _DYNAMIC + +.got 0x0000000000600848 0x8 + *(.got) + .got 0x0000000000600848 0x8 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + *(.igot) + 0x0000000000600850 . = (. DATA_SEGMENT_RELRO_END 0x18) + +.got.plt 0x0000000000600850 0x28 + *(.got.plt) + .got.plt 0x0000000000600850 0x28 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x0000000000600850 _GLOBAL_OFFSET_TABLE_ + *(.igot.plt) + .igot.plt 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + +.data 0x0000000000600878 0x4 + *(.data .data.* .gnu.linkonce.d.*) + .data 0x0000000000600878 0x4 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x0000000000600878 data_start + 0x0000000000600878 __data_start + .data 0x000000000060087c 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o + .data 0x000000000060087c 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + .data 0x000000000060087c 0x0 /tmp/ccHMG0n5.o + .data 0x000000000060087c 0x0 /usr/lib64/libc_nonshared.a(elf-init.oS) + .data 0x000000000060087c 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + .data 0x000000000060087c 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o + +.data1 + *(.data1) + +.sharable_data 0x0000000000800000 0x0 + 0x0000000000800000 PROVIDE (__sharable_data_start, .) + *(.sharable_data .sharable_data.* .gnu.linkonce.shrd.*) + 0x0000000000800000 . = ALIGN ((. != 0x0)?0x200000:0x1) + 0x0000000000800000 PROVIDE (__sharable_data_end, .) + 0x0000000000800000 _edata = . + 0x0000000000800000 PROVIDE (edata, .) + 0x0000000000800000 __bss_start = . + +.bss 0x0000000000600880 0x10 + *(.dynbss) + .dynbss 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + *(.bss .bss.* .gnu.linkonce.b.*) + .bss 0x0000000000600880 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + .bss 0x0000000000600880 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o + .bss 0x0000000000600880 0x10 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + .bss 0x0000000000600890 0x0 /tmp/ccHMG0n5.o + .bss 0x0000000000600890 0x0 /usr/lib64/libc_nonshared.a(elf-init.oS) + .bss 0x0000000000600890 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + .bss 0x0000000000600890 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o + *(COMMON) + 0x0000000000600890 . = ALIGN ((. != 0x0)?0x8:0x1) + +.lbss + *(.dynlbss) + *(.lbss .lbss.* .gnu.linkonce.lb.*) + *(LARGE_COMMON) + +.sharable_bss 0x0000000000800000 0x0 + 0x0000000000800000 PROVIDE (__sharable_bss_start, .) + *(.dynsharablebss) + .dynsharablebss + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + *(.sharable_bss .sharable_bss.* .gnu.linkonce.shrb.*) + *(SHARABLE_COMMON) + 0x0000000000800000 . = ALIGN ((. != 0x0)?0x200000:0x1) + 0x0000000000800000 PROVIDE (__sharable_bss_end, .) + 0x0000000000800000 . = ALIGN (0x8) + +.lrodata + *(.lrodata .lrodata.* .gnu.linkonce.lr.*) + +.ldata 0x0000000000a00890 0x0 + *(.ldata .ldata.* .gnu.linkonce.l.*) + 0x0000000000a00890 . = ALIGN ((. != 0x0)?0x8:0x1) + 0x0000000000a00890 . = ALIGN (0x8) + 0x0000000000a00890 _end = . + 0x0000000000a00890 PROVIDE (end, .) + 0x0000000000a00890 . = DATA_SEGMENT_END (.) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x2c + *(.comment) + .comment 0x0000000000000000 0x2c /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o + 0x2d (size before relaxing) + .comment 0x0000000000000000 0x2d /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o + .comment 0x0000000000000000 0x2d /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o + .comment 0x0000000000000000 0x2d /tmp/ccHMG0n5.o + .comment 0x0000000000000000 0x2d /usr/lib64/libc_nonshared.a(elf-init.oS) + .comment 0x0000000000000000 0x2d /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o + .comment 0x0000000000000000 0x2d /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges + *(.debug_aranges) + +.debug_pubnames + *(.debug_pubnames) + +.debug_info + *(.debug_info .gnu.linkonce.wi.*) + +.debug_abbrev + *(.debug_abbrev) + +.debug_line + *(.debug_line) + +.debug_frame + *(.debug_frame) + +.debug_str + *(.debug_str) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +.debug_pubtypes + *(.debug_pubtypes) + +.debug_ranges + *(.debug_ranges) + +.gnu.attributes + *(.gnu.attributes) + +/DISCARD/ + *(.note.GNU-stack) + *(.gnu_debuglink) + *(.gnu.lto_*) +OUTPUT(a.out elf64-x86-64) diff --git a/test.c b/test.c new file mode 100644 index 0000000..a18ec84 --- /dev/null +++ b/test.c @@ -0,0 +1,11 @@ +#include + +int main(void) +{ +#ifdef DEBUG + printf("Some smart debugcomment\n"); +#endif + printf("Hello, world!\n"); + return 0; +} + diff --git a/test2.c b/test2.c new file mode 100644 index 0000000..c2f9609 --- /dev/null +++ b/test2.c @@ -0,0 +1,12 @@ +#include +int debug = 0; +int main(void) +{ + if( debug ) + { + printf("Some smart debugcomment\n"); + } + printf("Hello, world!\n"); + return 0; +} +