This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFH] Fixing -fsection-anchors on powerpc-darwin
- From: Richard Sandiford <richard at codesourcery dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Sun, 19 Feb 2006 09:26:03 +0000
- Subject: Re: [RFH] Fixing -fsection-anchors on powerpc-darwin
- References: <9f4a4ff91e624d38e32a1795ac9bac27@physics.uc.edu>
Andrew Pinski <pinskia@physics.uc.edu> writes:
> Since -fsection-anchors is very useful for PPC-Darwin, I decided to
> see what I needed to do to support them.
> I started by just doing a bootstrap with them enabled by default
> and ran into the first issue of SET_ASM_OP not being set. Next
> I ran into the issue of quoting ". + 0" which caused the assembler
> to think it is a symbol instead of an addition of . and 0.
Have you thought about overriding the output_anchor hook for Darwin?
It sounds simpler than what you did in the patch, and the hook was
there specifically for cases where the ASM_OUTPUT_DEF thing wouldn't
work.
> The next issue I could not figure out how to fix, it is wrong code
> caused by merging constant strings together.
> Here is the reduced testcase (reduced from genmodes.c):
> int modes;
> emit_mode_class (void)
> {
> int t;
> for(t = 0;t<modes;t++)
> __builtin_puts ("");
> }
> int main(void)
> {
> char a[3] = "-h";
> if (!strcmp (a, "-h")) ; else __builtin_abort ();
> emit_mode_class ();
> }
>
> If someone could look into this, it would be nice, I think the use
> of .cstring and anchors are not supported together as .cstring section
> can be merged.
Right. This is handled for ELF by:
/* Don't use anchors for mergeable sections. The linker might move
the objects around. */
sect = SYMBOL_REF_BLOCK (symbol)->sect;
if (sect->common.flags & SECTION_MERGE)
return false;
in default_use_anchor_for_symbol_p. If .cstring contains mergeable
data, it sounds like you should either (a) set SECTION_MERGE for it
or (b) override use_anchor_for_symbol_p for Darwin and check whether
SYMBOL_REF_BLOCK (symbol)->sect == cstring_section.
Richard