1

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.

josecm
  • 413
  • 3
  • 15
  • Sorry Michael, I forgot to mention that. Yes, bss exists and the section actually has size. I updated my question. – josecm Jan 18 '19 at 17:18
  • Can you tell me what you are looking for? I am not at liberty to divulge much information about the code... – josecm Jan 19 '19 at 14:14

0 Answers0