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

2019-10-29  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: r277584

gcc/ChangeLog
gcc/config/darwin.c

index 047de28e51d61a5b0592723364f6b44108e4bf84..86aef482247ad2e812d6c90f9418abad4f62e7f2 100644 (file)
@@ -1,4 +1,15 @@
-2019-10-18  Iain Sandoe  <iain@sandoe.co.uk>
+2019-10-29  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-29  Iain Sandoe  <iain@sandoe.co.uk>
 
        Backport from mainline
        2019-09-21  Iain Sandoe  <iain@sandoe.co.uk>
index 17beaf01cf59d302dbe4326acd68bb1e5de1d201..7d89fd8bac1dd2ed6a7df9c8bf3e8e6879d8b0f9 100644 (file)
@@ -1255,12 +1255,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 *
@@ -1553,7 +1554,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: