public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: No .got section in ELF
@ 2009-11-27  4:51 Dmitry Gorbachev
  0 siblings, 0 replies; 17+ messages in thread
From: Dmitry Gorbachev @ 2009-11-27  4:51 UTC (permalink / raw)
  To: yunfeng zhang; +Cc: gcc

[-- Attachment #1: Type: text/plain, Size: 40 bytes --]

Yunfeng Zhang, please try this example.

[-- Attachment #2: elf.tar.gz --]
[-- Type: application/x-gzip, Size: 502 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread
* No .got section in ELF
@ 2009-11-24  1:58 yunfeng zhang
  2009-11-24 10:00 ` Andrew Haley
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: yunfeng zhang @ 2009-11-24  1:58 UTC (permalink / raw)
  To: gcc

The idea I got is about removing .got section in ELF format totally.

Before we go, let's see the limitation on the idea
1) It must be deployed on aligned segment model, such as Linux, which cs.start
= ds.start.
2) Currently, I only know how to do on x86 ELF.

Here is a typical sample in PIC model (shared library) when library want to
access its global data
    ...
    // Later code snippet template is used by gcc in almost all shared function
    // to imitate `mov %ip, %ebx'.
    call next:
next:
    pop %ebx // << A.
    ...
    movl new_offset(%ebx), %eax // << B. load global variable foo to eax.
    ...
    .global foo // << C.
OK!, to ld, offsetof(C - A) is const, and to gcc offsetof(B - A) is also
const, so to aligned segment model, new_offset = offset(C - A) - offset(B - A),
right?

Here is the new workflow
1) Using new option, such as, new option `--segment-model=aligned' to trigger
the feature.
2) Gcc creates a section (nogot) which stores data pair offsetof(B - A) and
new_offset address for every function.
3) Ld reads nogot section and update new_offset according to above formular.
4) nogot section is discarded later.
Constrast to traditional PIC code, we save an indirect memory load instruction
and shrink memory fee by avoiding to load .got section into memory. And it
seems it's fit with gcc4.5 link-time optimizer feature.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2009-11-30  7:27 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-27  4:51 No .got section in ELF Dmitry Gorbachev
  -- strict thread matches above, loose matches on Subject: below --
2009-11-24  1:58 yunfeng zhang
2009-11-24 10:00 ` Andrew Haley
2009-11-24 17:10 ` Richard Henderson
2009-11-26  2:24 ` yunfeng zhang
2009-11-26  3:11   ` Richard Henderson
2009-11-26  6:04     ` yunfeng zhang
2009-11-26  7:55       ` Alexandre Oliva
2009-11-27  2:18         ` yunfeng zhang
2009-11-27  4:12           ` Dave Korn
2009-11-27  4:43             ` yunfeng zhang
2009-11-27  4:46               ` Dave Korn
2009-11-27 13:35           ` Alexandre Oliva
2009-11-30 11:10             ` Yunfeng ZHANG
2009-11-27  4:58       ` Jie Zhang
2009-11-27  6:42         ` yunfeng zhang
2009-11-27 14:16           ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).