From a16ac18c60bf106fde60bcb722de03de8492a727 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu, 27 Aug 2020 19:39:10 +0100
Subject: [PATCH] Darwin, Arm64 : Make code label references use PAGE relocs

We need to be able to refer to Lxxxx labels in libgnat.

(cherry picked from commit 80a208d8f5d105bcca03de83c20eb020a0e6fcdf)
Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
---
 gcc/config/aarch64/aarch64.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git gcc/config/aarch64/aarch64.c gcc/config/aarch64/aarch64.c
index 0a43cefc270..a99cdedb513 100644
--- gcc/config/aarch64/aarch64.c
+++ gcc/config/aarch64/aarch64.c
@@ -10434,6 +10434,7 @@ output_macho_postfix_expr (FILE *file, rtx x, const char *postfix)
     case CODE_LABEL:
       ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
       assemble_name (file, buf);
+      fprintf (file, "@%s", postfix);
       break;
 
     case CONST_INT:
@@ -16643,7 +16644,9 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
 	case AARCH64_CMODEL_SMALL_SPIC:
 	case AARCH64_CMODEL_SMALL_PIC:
 	case AARCH64_CMODEL_SMALL:
-	  return SYMBOL_SMALL_ABSOLUTE;
+	  return TARGET_MACHO
+		 ? SYMBOL_MO_SMALL_PCR
+		 : SYMBOL_SMALL_ABSOLUTE;
 
 	default:
 	  gcc_unreachable ();
-- 
2.42.1

