[Bug target/59888] ld: illegal text-relocation to '_compute' ... on darwin1(2|3).
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888 --- Comment #6 from Francois-Xavier Coudert fxcoudert at gcc dot gnu.org --- (In reply to Iain Sandoe from comment #4) Whether this is a back-end fault or perhaps a constraint of darwin not present for binutils-ld I cannot tell immediately and would welcome input from the Fortran maintainers as to the decoration intended for the indirect reference produced for c_funloc (defined_function). Iain, I am willing to help there but do not understand exactly what you are asking for. Below is a short explanation of what the Fortran front-end is trying to do. Let's take this code, which compiles fine on darwin: module foo contains subroutine bar use, intrinsic :: iso_c_binding call gee(c_funloc(gee)) end subroutine subroutine gee(f) use, intrinsic :: iso_c_binding type(c_funptr), value :: f end subroutine end module foo Here GEE takes as single argument a function pointer, and has no return type. The code in BAR is equivalent to calling gee, with its own address as argument. Now, the second case passes the GEE argument by reference: module foo contains subroutine bar use, intrinsic :: iso_c_binding call gee(c_funloc(gee)) end subroutine subroutine gee(f) use, intrinsic :: iso_c_binding type(c_funptr) :: f end subroutine end module foo This generates the linker error: ld: illegal text-relocation to '___foo_MOD_gee' in a.o from 'anon' in a.o for architecture x86_64 If you look at the tree dump (-fdump-tree-original), you can see that instead of being just: bar () { gee(gee); } in the previous case, it now uses a temporary variable to pass by reference: bar () { static void (*T618) (void (*T68) (void) restrict) C.2324 = gee; gee (C.2324); } Let me know what else I can do to help solve this.
[Bug target/59888] ld: illegal text-relocation to '_compute' ... on darwin1(2|3).
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888 Francois-Xavier Coudert fxcoudert at gcc dot gnu.org changed: What|Removed |Added CC||fxcoudert at gcc dot gnu.org --- Comment #5 from Francois-Xavier Coudert fxcoudert at gcc dot gnu.org --- Reduced testcase, still failing with -shared on darwin14: module foo contains subroutine bar use, intrinsic :: iso_c_binding call gee(c_funloc(gee)) end subroutine subroutine gee(f) use, intrinsic :: iso_c_binding type(c_funptr) :: f end subroutine end module foo
[Bug target/59888] ld: illegal text-relocation to '_compute' ... on darwin1(2|3).
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888 Dominique d'Humieres dominiq at lps dot ens.fr changed: What|Removed |Added Summary|ld: warning: PIE disabled. |ld: illegal text-relocation |Absolute addressing |to '_compute' ... on |(perhaps -mdynamic-no-pic) |darwin1(2|3). |not allowed in code signed | |PIE ... | --- Comment #3 from Dominique d'Humieres dominiq at lps dot ens.fr --- Changed the summary to reflect the original post.
[Bug target/59888] ld: illegal text-relocation to '_compute' ... on darwin1(2|3).
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888 --- Comment #4 from Iain Sandoe iains at gcc dot gnu.org --- So, essentially, the complaint from the darwin linker is that it does not want to see a relocation in the .const section (which is part of the text segment). It might be argued that this is right/wrong - but it is at least reasonable - the relevant segment should be marked read-only .. but typical darwin relocs can be re-written lazily (as and when the symbol is required). the hack, proof-of-principle, solution above was to move the reference to the .const_data section. Whether this is a back-end fault or perhaps a constraint of darwin not present for binutils-ld I cannot tell immediately and would welcome input from the Fortran maintainers as to the decoration intended for the indirect reference produced for c_funloc (defined_function).