Darwin's linker doesn't like text section relocations (they require special enabling). At least, the Fortran FE seems to generate cases where the initialiser for a pointer constant can need a relocation. We can handle this by special-casing SECCAT_RODATA when the relocation is present by placing the constant in the .const_data section.
tested on x86_64-darwin16, applied to mainline, thanks Iain gcc/ChangeLog: 2019-10-05 Iain Sandoe <i...@sandoe.co.uk> PR target/59888 * config/darwin.c (darwin_rodata_section): Add relocation flag, choose const_data section for constants with relocations. (machopic_select_section): Pass relocation flag to darwin_rodata_section (). diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 3a1be5a29b..2fb9c56c72 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1251,12 +1251,13 @@ darwin_mark_decl_preserved (const char *name) } static section * -darwin_rodata_section (int use_coal, bool zsize) +darwin_rodata_section (int use_coal, bool zsize, int reloc) { return (use_coal ? darwin_sections[const_coal_section] : (zsize ? darwin_sections[zobj_const_section] - : darwin_sections[const_section])); + : reloc ? darwin_sections[const_data_section] + : darwin_sections[const_section])); } static section * @@ -1549,7 +1550,7 @@ machopic_select_section (tree decl, case SECCAT_RODATA: case SECCAT_SRODATA: - base_section = darwin_rodata_section (use_coal, zsize); + base_section = darwin_rodata_section (use_coal, zsize, reloc); break; case SECCAT_RODATA_MERGE_STR: