Note that there are some explanatory texts on larger screens.

plurals
  1. POlocation counter in linker script
    primarykey
    data
    text
    <p>I was thinking that I understand the working the location counter in linker script but I guess it's not so. I just did a simple test to confirm what I understand. I wrote a simple c program without any library calls and compiled it with gcc. Then I linked it using a linker script with the location counter set to value in the beginning. Here is the program</p> <pre><code>int a = 6; int main(){ return 0; } </code></pre> <p>Following is the linker script</p> <pre><code>ENTRY(main) addr = 0x8048000; SECTIONS { .text addr : ALIGN(0x1000) { *(text*); *(.rodata*); } .data : ALIGN(0x1000) { *(.data*); } } </code></pre> <p>I didn't want to execute it but just see the objdump output. I was thinking that when I do <code>objdump -s</code> on the elf it should show the starting address as 0x8048000. However I always see the starting address as 0000</p> <pre><code>Contents of section .text: 0000 b8000000 00c3 ...... Contents of section .data: 1000 06000000 .... Contents of section .comment: 0000 4743433a 20285562 756e7475 20342e34 GCC: (Ubuntu 4.4 0010 2e332d34 7562756e 74753529 20342e34 .3-4ubuntu5) 4.4 0020 2e3300 </code></pre> <p>Besides there is a comment section which also starts from 0000. I don't understand what is going on.</p> <p>Here is the output of objdump without the linker script (still without any libraries)</p> <pre><code>Contents of section .text: 8048094 b8000000 00c3 ...... Contents of section .data: 804909c 06000000 .... Contents of section .comment: 0000 4743433a 20285562 756e7475 20342e34 GCC: (Ubuntu 4.4 0010 2e332d34 7562756e 74753529 20342e34 .3-4ubuntu5) 4.4 0020 2e3300 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload