On 05/04/2018 09:57, Mason wrote: > On 05/04/2018 08:07, Hao Lee wrote: > >> I'm confused about the location counter, especially when setting it to >> a new value in the output section. >> >> I write a simple program and a linker script to make my question more >> clear. The code is as follows: [snip] >> >> I can't understand why lable_2 is 0x30. As the LD documentation >> says[1], if '.' is used inside a section description, it refers to the >> byte offset from the start of that section, not an absolute address. >> In the custom_section, '.' is set to 0x20 which is a relative address, >> so I think label_2 should also be 0x20. However, label_2 is 0x30. (The >> value of label_3 is reasonable because it's an absolute address.) >> >> Could someone please explain why label_2 is 0x30? Thanks! >> >> [1] https://sourceware.org/binutils/docs-2.30/ld/Location-Counter.html#Location-Counter > > Hello, > > 'gas' (GNU assembler) and 'ld' (GNU linker) are Binutils tools. > AFAIU, Binutils and GCC are separate projects -- with GCC producing > assembly code processed by gas and then ld. > > Thus, you might have better luck asking on the binutils mailing list: > > binutils@xxxxxxxxxxxxxx > > https://sourceware.org/ml/binutils/ Oops, I'm sorry, I had not noticed that you had, in fact, already posted to the binutils ML. https://sourceware.org/ml/binutils/2018-04/msg00021.html Looks like Alan Modra answered your question. Regards.