public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Relocations put in read-only segment?
@ 1998-04-23 23:23 Charles M. Hannum
  1998-04-24 16:23 ` Jeffrey A Law
  0 siblings, 1 reply; 7+ messages in thread
From: Charles M. Hannum @ 1998-04-23 23:23 UTC (permalink / raw)
  To: egcs

When I compile the following code with egcs 1.0.2, using `-O -fPIC',
on either i386-*-netbsd or i586-*-linux-gnulibc1, the relocation for
`XtStrings+788' is put in a read-only section (the text section under
NetBSD, rodata under Linux).  While it's true that ld.so on both
platforms is careful to make this work, it's canonically wrong.  If
the relocation is done in a data section at all, it should be in a
writable section.


The code in question (whittled down from a case in Xaw3d):

extern const  char XtStrings[];
void NotifyThumb (top)
    float top;
{
    XtCallCallbacks (&XtStrings[788], top + 0.0001);
}

Under egcs 1.0.2, the reference to XtStrings is compiled as:

.text
[...]
LC1:
        .long _XtStrings+788
        .align 2
[...]
        pushl LC1@GOTOFF(%ebx)

whereas, under gcc 2.7.2.2, it's compiled as:

.text
[...]
        movl _XtStrings@GOT(%ebx),%eax
        addl $788,%eax
        pushl %eax


Anyone know why this happens, or do I need to track it down myself?


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

* Re: Relocations put in read-only segment?
  1998-04-23 23:23 Relocations put in read-only segment? Charles M. Hannum
@ 1998-04-24 16:23 ` Jeffrey A Law
  1998-04-24 16:23   ` Charles M. Hannum
                     ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Jeffrey A Law @ 1998-04-24 16:23 UTC (permalink / raw)
  To: Charles M. Hannum; +Cc: egcs

  In message < 199804240119.VAA15305@lunacity.ne.mediaone.net >you write:
  > When I compile the following code with egcs 1.0.2, using `-O -fPIC',
  > on either i386-*-netbsd or i586-*-linux-gnulibc1, the relocation for
  > `XtStrings+788' is put in a read-only section (the text section under
  > NetBSD, rodata under Linux).  While it's true that ld.so on both
  > platforms is careful to make this work, it's canonically wrong.  If
  > the relocation is done in a data section at all, it should be in a
  > writable section.
This is a pretty common problem; generally it's fixed by having
SELECT_SECTION and related functions put these things into the
data section for PIC code generation.  Unfortunately many ports
do not handle this case correctly.

jeff


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

* Re: Relocations put in read-only segment?
  1998-04-24 16:23 ` Jeffrey A Law
  1998-04-24 16:23   ` Charles M. Hannum
  1998-04-24 16:23   ` Charles M. Hannum
@ 1998-04-24 16:23   ` Charles M. Hannum
  1998-04-25 17:40     ` Jeffrey A Law
  1998-04-25 16:18   ` Richard Henderson
  3 siblings, 1 reply; 7+ messages in thread
From: Charles M. Hannum @ 1998-04-24 16:23 UTC (permalink / raw)
  To: law; +Cc: egcs

Well, I solved the problem by changing SELECT_RTX_SECTION() in our
source tree.  Thanks for the pointer.

(We have a bunch of other changes to merge into the egcs tree, which
I'll get to RSN...)


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

* Re: Relocations put in read-only segment?
  1998-04-24 16:23 ` Jeffrey A Law
  1998-04-24 16:23   ` Charles M. Hannum
@ 1998-04-24 16:23   ` Charles M. Hannum
  1998-04-24 16:23   ` Charles M. Hannum
  1998-04-25 16:18   ` Richard Henderson
  3 siblings, 0 replies; 7+ messages in thread
From: Charles M. Hannum @ 1998-04-24 16:23 UTC (permalink / raw)
  To: law; +Cc: egcs

Jeffrey A Law <law@hurl.cygnus.com> writes:

>   In message < 199804240119.VAA15305@lunacity.ne.mediaone.net >you write:
>   > When I compile the following code with egcs 1.0.2, using `-O -fPIC',
>   > on either i386-*-netbsd or i586-*-linux-gnulibc1, the relocation for
>   > `XtStrings+788' is put in a read-only section (the text section under
>   > NetBSD, rodata under Linux).  While it's true that ld.so on both
>   > platforms is careful to make this work, it's canonically wrong.  If
>   > the relocation is done in a data section at all, it should be in a
>   > writable section.
> This is a pretty common problem; generally it's fixed by having
> SELECT_SECTION and related functions put these things into the
> data section for PIC code generation.  Unfortunately many ports
> do not handle this case correctly.

That doesn't quite follow.  There is currently no SELECT_SECTION on
the platforms I mentioned.  This means they use the default code:

      if (DECL_READONLY_SECTION (decl, reloc))
        readonly_data_section ();
      else
        data_section ();

Note that DECL_READONLY_SECTION specifically does:

   && ! (RELOC && (flag_pic || DECL_ONE_ONLY (DECL))))

This implies that `reloc' is false in this case, which would be a bug.


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

* Re: Relocations put in read-only segment?
  1998-04-24 16:23 ` Jeffrey A Law
@ 1998-04-24 16:23   ` Charles M. Hannum
  1998-04-24 16:23   ` Charles M. Hannum
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Charles M. Hannum @ 1998-04-24 16:23 UTC (permalink / raw)
  To: law; +Cc: egcs

> That doesn't quite follow.  There is currently no SELECT_SECTION on
> the platforms I mentioned.  This means they use the default code:

Hmmm.  It's even worse than that.  It's not going through either of
the pieces of code that use SELECT_SECTION() at all.

Yuck.


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

* Re: Relocations put in read-only segment?
  1998-04-24 16:23 ` Jeffrey A Law
                     ` (2 preceding siblings ...)
  1998-04-24 16:23   ` Charles M. Hannum
@ 1998-04-25 16:18   ` Richard Henderson
  3 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 1998-04-25 16:18 UTC (permalink / raw)
  To: law; +Cc: Charles M. Hannum, egcs

On Fri, Apr 24, 1998 at 01:53:05PM -0600, Jeffrey A Law wrote:
> This is a pretty common problem; generally it's fixed by having
> SELECT_SECTION and related functions put these things into the
> data section for PIC code generation.  Unfortunately many ports
> do not handle this case correctly.

Actually, Jeff,

]        pushl LC1@GOTOFF(%ebx)                                       
    vs
]        movl _XtStrings@GOT(%ebx),%eax
]        addl $788,%eax                    
]        pushl %eax

is a code gen issue and has nothing to do with SELECT_SECTION. 
This would have to do with GO_IF_LEGITIMATE_ADDRESS and friends.

But I don't replicate it with the given example and 19980418.


r~

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

* Re: Relocations put in read-only segment?
  1998-04-24 16:23   ` Charles M. Hannum
@ 1998-04-25 17:40     ` Jeffrey A Law
  0 siblings, 0 replies; 7+ messages in thread
From: Jeffrey A Law @ 1998-04-25 17:40 UTC (permalink / raw)
  To: Charles M. Hannum; +Cc: egcs

  In message < el2ra2mho8n.fsf@lunacity.ne.mediaone.net >you write:
  > (We have a bunch of other changes to merge into the egcs tree, which
  > I'll get to RSN...)
Cool.

Not sure who "we" is, but as you know, we'll probably need copyright
assignments for significant contributions.

jeff

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

end of thread, other threads:[~1998-04-25 17:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-23 23:23 Relocations put in read-only segment? Charles M. Hannum
1998-04-24 16:23 ` Jeffrey A Law
1998-04-24 16:23   ` Charles M. Hannum
1998-04-24 16:23   ` Charles M. Hannum
1998-04-24 16:23   ` Charles M. Hannum
1998-04-25 17:40     ` Jeffrey A Law
1998-04-25 16:18   ` Richard Henderson

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).