This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: gold - Addresses of zero-initialized globals are not shown in Mapfile
- From: "Koehrer Mathias (ETAS/ESW5)" <mathias dot koehrer at etas dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Mon, 5 Sep 2016 12:05:04 +0000
- Subject: Re: gold - Addresses of zero-initialized globals are not shown in Mapfile
- Authentication-results: sourceware.org; auth=none
> Hi all,
>
> In a project we switched from "ld" to "gold". The performance is great!
> Version of gold:
> GNU gold (GNU Binutils for Debian 2.25) 1.11
>
> However there is one issue I want to solve:
> I do not see the addresses of global zero initialized variables in the map file!
>
> Example:
> I have the following tiny C-source code (t.c):
>
> int global_zero;
> int global_one = 1;
> int main(void)
> {
> return 0;
> }
>
> I compile this on a Linux x86-64 (amd64) machine:
> gcc -Wl,-fuse-ld=gold -Xlinker -Map=Mapfile t.c In the Mapfile I can see the
> following:
> -----------------------------------------------------
> ...
> Allocating common symbols
> Common symbol size file
>
> global_zero 0x4 /tmp/cc3JpgFt.o
> ...
> .data 0x0000000000401930 0x4 /tmp/cc3JpgFt.o
> 0x0000000000401930 global_one
> .data 0x0000000000401934 0x0 /usr/lib/x86_64-linux-
> gnu/libc_nonshared.a(elf-init.oS)
> ...
> -----------------------------------------------------
>
> The address of global_one is shown, the address of global_zero is not shown!
>
>
>
> When I compile the same code using the linker "ld":
> gcc -Wl,-fuse-ld=gold -Xlinker -Map=Mapfile t.c I got the following information in the
> Mapfile:
Typo: Must be
gcc -Xlinker -Map=Mapfile t.c
> -----------------------------------------------------
> ...
> Allocating common symbols
> Common symbol size file
>
> global_zero 0x4 /tmp/ccjPds2R.o
> ...
> .data 0x00000000006008a8 0x4 /tmp/ccjPds2R.o
> 0x00000000006008a8 global_one
> ...
>
> *(COMMON)
> *fill* 0x00000000006008ad 0x3
> COMMON 0x00000000006008b0 0x4 /tmp/ccjPds2R.o
> 0x00000000006008b0 global_zero
> ...
> -----------------------------------------------------
>
> Here I can see both addresses of global_one and global_zero.
>
> My question is now:
> How can I force the "gold" linker to output also the address of the zero-initialized
> variables?
> Is there any command line argument I can use for that?
>
> Thanks for any feedback on this question:
>
>
> Best regards
>
> Mathias
>