This is the mail archive of the 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: common symbols and GNU ld

ali hagigat <> writes:

> FORCE_COMMON_ALLOCATION is not only for relocatable linking but also
> for other types of linking. The document says that:
> "This command has the same effect as the â-dâ command-line option: to
> make ld assign space to common symbols even if a relocatable output
> file is specified(â-râ)."
> The document says that even if a relocatable output file is specified,
> it means that if you specify other types of file it works too.

FORCE_COMMON_ALLOCATION is the default when not using -r.

> asm2.s
> .comm dovom, 10
> aval:
> movl %edx, 32(%edi)
> asm3.s
> .section .text
> .comm dovom, 10
> aval:
> movl $26, %eax
> asm2.ld
> as asm2.s -o asm2.o
> as asm3.s -o asm3.o
> ld asm2.o asm3.o -T asm2.ld -o asm2
> The result:
> asm2:     file format elf32-i386
> 00000000 l    d  .text  00000000 .text
> 00000010 l    d  .bss   00000000 .bss
> 00000000 l       .text  00000000 aval
> 00000004 l       .text  00000000 aval
> 00000010 g     O .bss   0000000a dovom
> --------------------------------------------
> In this example if I create, asm2.ld, as an empty file, it means if
> the content of this file is empty and nothing has been written, the
> resulted symbol table is the same.
> The manual says that  FORCE_COMMON_ALLOCATION forces 'space to be
> considered for symbols'  but this command has no effect as the above
> shows and space is considered no matter if I use

Yes.  That is how it works.

> and my last question is that I have defined "dovom" two times as a
> common symbol and forced the linker to consider space for it, so the
> linker should consider the space for this variable two times for each
> file and I should see two lines for "dovom" in the resulted final
> symbol table. But why i see only one line?

Because you've said that dovom is a common symbol.  The definition of a
common symbol is that all instances of the symbol are combined into
one.  A linker common symbol implements the semantics of a FORTRAN
COMMON block.


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