]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Darwin] Amend section for constants with relocations.
authorIain Sandoe <iain@sandoe.co.uk>
Fri, 18 Oct 2019 08:42:41 +0000 (08:42 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Fri, 18 Oct 2019 08:42:41 +0000 (08:42 +0000)
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  <iain@sandoe.co.uk>

Backport from mainline
2019-10-05  Iain Sandoe  <iain@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 ().

From-SVN: r277145

gcc/ChangeLog
gcc/config/darwin.c

index ae17be5a74c40c4531a7dd76049e5711acb06be9..9179ad4b3b6106ebbc3a9cf1f4c2033e5df7a899 100644 (file)
@@ -1,3 +1,14 @@
+2019-10-18  Iain Sandoe  <iain@sandoe.co.uk>
+
+       Backport from mainline
+       2019-10-05  Iain Sandoe  <iain@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 ().
+
 2019-10-18  Iain Sandoe  <iain@sandoe.co.uk>
 
        Backport from mainline
index 5e0110c48d94d3d914f8dfff803e094299ed3619..55759df79c8af37b76d0eae0eddb3e87e72107d0 100644 (file)
@@ -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: