https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116887
--- Comment #17 from chenglulu <chenglulu at loongson dot cn> ---
(In reply to Xi Ruoyao from comment #16)
> (In reply to chenglulu from comment #15)
> > (In reply to chenglulu from comment #14)
> > > (In reply to Xi Ruoyao from comment #13)
> > > > Hmm I do think 2 is better. It seems we are just "reinventing" the GOT
> > > > in 1.
> > > >
> > > > So OK with your approach if it passes regtest.
> > >
> > > I agree, I'll test the patch
> >
> > extern struct rtld_global _rtld_global;
> > static struct dl_find_object_internal _dlfo_main __attribute__ ((section
> > (".data.rel.ro")));
> > extern void _dlfo_process_initial_noncontiguous_map (void);
> > void
> > _dlfo_process_initial (void)
> > {
> > if ( _dlfo_main.map == &_rtld_global._dl_rtld_map)
> > _dlfo_process_initial_noncontiguous_map ();
> > }
> >
> >
> > I've been looking at this code for the past two days, and I think the second
> > modification is incomplete. The reason for the problem is:
> >
> > If decls are put in ".data.rel.ro" or ".data.rel.ro.local" using the
> > __attribute__ construct (_dlfo_main), then the obtained section flags
> > contain only SECTION_WRITE and not SECTION_RELRO.
> > But labels are placed in the constant pool ("data.rel.ro" or
> > "data.rel.ro.local") (_rtld_global._dl_rtld_map), the section flags contain
> > both SECTION_WRITE and SECTION_RELRO.
> > Since two sections are the same, but the flags are set differently, then can
> > cause a section conflicts.
>
> So can we avoid putting labels into constant pool? If not we'll have to use
> patch 1 like hppa.
I don't think it can be completely avoided. But I don't understand why the
public code does not set the SECTION_RELRO flag when putting decl into
".data.rel.ro" via __attribute__.