This is the mail archive of the binutils@sourceware.org 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]

.got increase in -gc-sections for MIPS


Hi,

While trying -ffunction-sections -fdata-sections -Wl,-gc-sections
combination to omit unreferenced func/data, I observed an increase in
.got section, while other sections such as .text and .data did decrease.

I'm using binutils-2.16, glibc-2.3.6, gcc-3.4.4 combination.

Here is a sample:

   *   *   *   *   *   *   *   *

$ cat foo.c 
#include <stdio.h>
void foo(){printf("foo\n");}

$ cat bar.c 
#include <stdio.h>
void bar(){printf("bar\n");}

$ cat main.c 
#include <stdio.h>
extern void foo();
extern void bar();
void baz(){printf("baz\n");}
int main()
{
        foo();
        return 0;
}

$ mips-linux-gcc foo.c bar.c main.c -o test-gc -ffunction-sections -fdata-sections -Wl,-gc-sections

$ mips-linux-readelf -S test-gc | grep got
[19] .got              PROGBITS        10000020 010020 00006c 04 WAp  0   0 16

$ mips-linux-readelf -d test-gc | grep GOT 
 0x00000003 (PLTGOT)                     0x10000020
 0x7000000a (MIPS_LOCAL_GOTNO)           13
 0x70000013 (MIPS_GOTSYM)                0x4

$ mips-linux-readelf -x 19 test-gc 

Hex dump of section '.got':
  0x10000020 00000000 80000000 00400000 10000000 .........@......
  0x10000030 00000000 00000000 00000000 00000000 ................
  0x10000040 00000000 00000000 00000000 00000000 ................
  0x10000050 00000000 004004b8 0040070c 10000000 .....@...@......
  0x10000060 10000000 10000000 004008e0 00400760 .........@...@.`
  0x10000070 004006c0 004008d0 00400900 00000000 .@...@...@......
  0x10000080 00000000 10000000 004007d8          .........@..

   *   *   *   *   *   *   *   *

To compare:

$ mips-linux-gcc foo.c bar.c main.c -o test
$ mips-linux-readelf -S test | grep got
[21] .got              PROGBITS        10000060 010060 000058 04 WAp  0   0 16

$ mips-linux-readelf -d test | grep GOT
 0x00000003 (PLTGOT)                     0x10000060
 0x7000000a (MIPS_LOCAL_GOTNO)           8
 0x70000013 (MIPS_GOTSYM)                0x4

$ mips-linux-readelf -x 21 test    

Hex dump of section '.got':
  0x10000060 00000000 80000000 00400000 10000000 .........@......
  0x10000070 00000000 00000000 00000000 00000000 ................
  0x10000080 00400530 0040082c 10000000 10000000 .@.0.@.,........
  0x10000090 10000000 00400a00 00400880 00400740 .....@...@...@.@
  0x100000a0 004009f0 00400a20 00000000 00000000 .@...@. ........
  0x100000b0 10000000 004008f8                   .....@..

   *   *   *   *   *   *   *   *

Is this increase in .got intended?
In a bigger test application, the MIPS_LOCAL_GOTNO increased from 19 to 251,
and I was astonished.


Thanks in Advance.


(Hiroki Kaminaga)
--


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