This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [PATCH] for PR middle-end/31490


"Dinar Temirbulatov" <dtemirbulatov@gmail.com> writes:

> This patch fixes PR31490,  bootstrapped and regtested on
> i686-pc-linux-gnu with no new regressions and still continue to
> testing. OK for trunk?
>                thanks, Dinar.
> 
> 2007-05-03 Dinar Temirbulatov <dtemirbulatov@gmail.com>
> 	PR middle-end/31490
> 	* varasm.c(decl_readonly_section): True for SECCAT_DATA_REL_RO,
>         SECCAT_DATA_REL_RO_LOCAL.

This does not look correct.  SECCAT_DATA_REL_RO and
SECCAT_DATA_REL_RO_LOCAL are only used when TARGET_ASM_RELOC_RW_MASK
returns non-zero.  That is documented as:

    Return a mask describing how relocations should be treated when
    selecting sections.  Bit 1 should be set if global relocations
    should be placed in a read-write section; bit 0 should be set if
    local relocations should be placed in a read-write section.

    The default version of this function returns 3 when @option{-fpic}
    is in effect, and 0 otherwise.  The hook is typically redefined
    when the target cannot support (some kinds of) dynamic relocations
    in read-only sections even in executables.

Currently, this means that if you compile

int cpu_ (void *attr) {}
const unsigned long _1 __attribute__((section("__"))) =  (unsigned long)&cpu_ ;

with -fpic, the variable will be put into a section declared as

	.section	__,"aw",@progbits

It appears that your patch will change this to a section declared as

	.section	__,"a",@progbits

In other words, a read-only section.  This contradicts the explicit
intention of TARGET_ASM_RELOC_RW_MASK.

I think the correct patch is going to be to ignore
TARGET_ASM_RELOC_RW_MASK for a named section.

Ian


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