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 as usual.
If Mike can recall any reason that they should be in the .data section, we can revise that - but testing hasn’t revealed any issues so far. Tested on x86_64-darwin16, powerpc-darwin9. applied to mainline. thanks, Iain gcc/ChangeLog: 2019-10-10 Iain Sandoe <i...@sandoe.co.uk> * config/darwin.c: Lookup Objective C metadata and force indirection for IVAR refs. diff --git a/gcc/REVISION b/gcc/REVISION index a7c33b8bba..44c108c456 100644 --- a/gcc/REVISION +++ b/gcc/REVISION @@ -1 +1 @@ -[trunk revision 276847] +[trunk revision 276848] diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index f490f622fc..539ef759d3 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