I want to set symbols to the start and end of a section, so a define my section like this:
.mysec : {
_mysec_start = .;
*(.bss)
*(COMMON)
_mysec_end = .;
}
However, I get the same value for both start and end symbols which is equivalent to the end of the section (i.e., the _mysec_end symbol has the expected value):
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 6] .mysec NOBITS 0000ff0000009000 00019000
0000000000000228 0000000000000000 WA 0 0 8
Symbol table:
Num: Value Size Type Bind Vis Ndx Name
139: 0000ff0000009228 0 NOTYPE GLOBAL DEFAULT 6 _mysec_start
160: 0000ff0000009228 0 NOTYPE GLOBAL DEFAULT 6 _mysec_end
What am I getting wrong? I believe I saw people do this in linker scripts in the past.
EDIT: found the problem. It actually was a bug in my Makefile. I was passing the linker script two times as an argument to ld. I believe this would make the symbols to be evaluated a second time after all the input sections were consumed for the final output section.