From 3a73cd7c9d4e51013aa526988e154a73b86e4970 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Thu, 10 Oct 2019 19:14:07 +0000 Subject: [PATCH] [Darwin, machopic 4/n] Arrange to indirect IVARs when needed. Objective C V2 (m64) IVAR offset refs from Apple GCC-4.x have an indirection for m64 code on PPC (which is the only 64b user for Mach-O PIC). Apple GCC 4.x places the indirections in the .data section, however this seems to have been unintentional - and we are placing the indirections in the non-lazy symbol pointers section. gcc/ChangeLog: 2019-10-10 Iain Sandoe * config/darwin.c: Lookup Objective C metadata and force indirection for IVAR refs. From-SVN: r276848 --- gcc/ChangeLog | 5 +++++ gcc/config/darwin.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fea00853702..f91ff7ec8c4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-10-10 Iain Sandoe + + * config/darwin.c: Lookup Objective C metadata and force indirection + for IVAR refs. + 2019-10-10 Michael Meissner * config/rs6000/rs6000.c (quad_address_p): Add check for prefixed diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index f490f622fc3..539ef759d31 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1270,6 +1270,17 @@ darwin_encode_section_info (tree decl, rtx rtl, int first) || (DECL_WEAK (decl) && ! MACHO_SYMBOL_HIDDEN_VIS_P (sym_ref)) || lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))) SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_MUST_INDIRECT; + +#if DARWIN_PPC + /* Objective C V2 (m64) IVAR offset refs from Apple GCC-4.x have an + indirection for m64 code on PPC. Historically, these indirections + also appear in the .data section. */ + tree o2meta = lookup_attribute ("OBJC2META", DECL_ATTRIBUTES (decl)); + o2meta = o2meta ? TREE_VALUE (o2meta) : NULL_TREE; + + if (o2meta && strncmp (IDENTIFIER_POINTER (o2meta), "V2_IVRF",7) == 0) + SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_MUST_INDIRECT; +#endif } void -- 2.30.2