https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116887
--- Comment #25 from chenglulu <chenglulu at loongson dot cn> --- (In reply to Xi Ruoyao from comment #22) > (In reply to Florian Weimer from comment #18) > > (In reply to chenglulu from comment #17) > > > 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__. > > > > I'm not aware of a way to set the RELRO flag directly. We want to write to > > these variables during initialization, so we cannot make them const. I > > assume we could move the definition into a separate TU and only have the > > section attribute on a definition. This would then rely on more relaxed > > section merging in the linker. The particular instance that triggered this > > bug report would be fairly straightforward to fix, but doing this for e.g. > > _rtld_global_ro is more difficult. > > In PR47610 fix (r169855) SECTION_RELRO is (intentionally??) only applied for > decl == NULL. > > So should we just extend it to cover decl != NULL, i.e. something like > I think it should be like this.