https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84553
Bug ID: 84553 Summary: -rdynamic generates TEXTREL relocations on ia64 Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at inbox dot ru Target Milestone: --- This is a trimmed-down version of gcc compiling itself with TEXTRELs on ia64: https://bugs.gentoo.org/566118 Minimal reproducer: // cat lto-lang.c struct a { int (*b)(void); int c; }; int d(void) {} const struct a e = { &d, 0, }; int main(){} $ LANG=C ia64-unknown-linux-gnu-gcc -O0 -no-pie -fno-PIE lto-lang.c -o lto-lang -Wl,-z,text -rdynamic /usr/libexec/gcc/ia64-unknown-linux-gnu/ld: read-only segment has dynamic relocations. collect2: error: ld returned 1 exit status Used version: binutils-2.30 (older 2.29 is also affected), gcc-HEAD (older 6.4.0 is also affected) I'm not sure who exactly is at fault here: gcc or binutils. What happens here is: 'const struct e' (with .text pointer) is placed into '.rodata' by gcc and later is merged into '.text'. What I suspect should happen: 'const struct e' (with .text pointer) is placed into '.data.rel.ro' by gcc and later is merged into '.data'?