https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82501
--- Comment #25 from Andrey Drobyshev <a.drobyshev at samsung dot com> --- (In reply to Martin Liška from comment #23) > (In reply to Andrey Drobyshev from comment #22) > > Created attachment 45851 [details] > > Work-in-progress fix considering relocations > > > > I'm a bit stuck. I managed to precompute reloc value for the globals (the > > code for detect_reloc_for_node() is stealed from get_variable_section ()). I > > also succeded in putting dummy variable into .data.rel.ro by making a decl > > of a pointer type. > > Nice progress! > > > But .data.rel is not working: checks from varasm.c:1173 > > and varasm.c:1197 are somewhat conflicting. Maybe you could find a way to > > overcome this? > > Can you please paste content of the lines, the lines you mentioned point to > a '}' for me. Sorry for the delay, was out of the office for a couple of weeks... What I actually meant was the following: setting DECL_INITIAL to error_mark_node and making the decl of pointer type for computing the right reloc here: if (DECL_INITIAL (decl) == error_mark_node) reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0; else if (DECL_INITIAL (decl)) reloc = compute_reloc_for_constant (DECL_INITIAL (decl)); else reloc = 0; along with making the decl non read only (as we want to put it in the data.rel) causes it to be put in .bss here (in particular, because bss_initializer_p (decl) becomes true): if (ADDR_SPACE_GENERIC_P (as) && !DECL_THREAD_LOCAL_P (decl) && !(prefer_noswitch_p && targetm.have_switchable_bss_sections) && bss_initializer_p (decl)) { if (!TREE_PUBLIC (decl) && !((flag_sanitize & SANITIZE_ADDRESS) && asan_protect_global (decl))) return lcomm_section; if (bss_noswitch_section) return bss_noswitch_section; }