From: Iain Sandoe Date: Fri, 18 Oct 2019 08:42:41 +0000 (+0000) Subject: [Darwin] Amend section for constants with relocations. X-Git-Tag: releases/gcc-9.3.0~534 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b236c5474161ec727697a4d64cf9d786697a9b4;p=thirdparty%2Fgcc.git [Darwin] Amend section for constants with relocations. Darwin's linker doesn't like text section relocations (they require special enabling). The Fortran FE, at least, 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. gcc/ 2019-10-18 Iain Sandoe Backport from mainline 2019-10-05 Iain Sandoe 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 (). From-SVN: r277145 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ae17be5a74c4..9179ad4b3b61 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2019-10-18 Iain Sandoe + + Backport from mainline + 2019-10-05 Iain Sandoe + + 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 (). + 2019-10-18 Iain Sandoe Backport from mainline diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 5e0110c48d94..55759df79c8a 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1252,12 +1252,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 * @@ -1550,7 +1551,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: