This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: help on common symbols


"Vineet Sharma, Noida" <vineets@noida.hcltech.com> writes:

>          Suppose we have an example as given below, So what logic decides
> the address of common symbol "_x"  and what would be the address filled at
> line5?What special handling is needed for coomon symbols? 
> 
> 
> 
> .global _y				//line 1
>         .data			//line2
>         .align  1			//line3
> _y:					//line4
>         .short  _x+28		//line5
>         .global _z		//line6
>         .align  1			//line7
> _z:					//line8
>         .short  1			//line 9
>         .comm _x,120		//line 10
>         .end			//line 11

When you link the program, the linker allocates space for common
symbols.  They are placed as directed by the linker script, normally
into the .bss section.

Line 5 generates a relocation against the symbol `x'.  The relocation
is computed by the linker after the address of x is known.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]