mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 04:09:45 +00:00
a23cc6a1ea
The fixes are to note that AArch64 has additional restrictions on when local relocations can be used. In particular, ld64 requires that relocations to cstring/cfstrings use linker visible symbols. Original message: In an assembly expression like bar: .long L0 + 1 the intended semantics is that bar will contain a pointer one byte past L0. In sections that are merged by content (strings, 4 byte constants, etc), a single position in the section doesn't give the linker enough information. For example, it would not be able to tell a relocation must point to the end of a string, since that would look just like the start of the next. The solution used in ELF to use relocation with symbols if there is a non-zero addend. In MachO before this patch we would just keep all symbols in some sections. This would miss some cases (only cstrings on x86_64 were implemented) and was inefficient since most relocations have an addend of 0 and can be represented without the symbol. This patch implements the non-zero addend logic for MachO too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226503 91177308-0d34-0410-b5e6-96231b3b80d8
94 lines
2.9 KiB
C++
94 lines
2.9 KiB
C++
//===-- MCAsmInfoDarwin.cpp - Darwin asm properties -------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines target asm properties related what form asm statements
|
|
// should take in general on Darwin-based targets
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/MC/MCAsmInfoDarwin.h"
|
|
#include "llvm/MC/MCContext.h"
|
|
#include "llvm/MC/MCExpr.h"
|
|
#include "llvm/MC/MCSectionMachO.h"
|
|
#include "llvm/MC/MCStreamer.h"
|
|
using namespace llvm;
|
|
|
|
bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(
|
|
const MCSection &Section) const {
|
|
const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);
|
|
|
|
// Sections holding 1 byte strings are atomized based on the data they
|
|
// contain.
|
|
// Sections holding 2 byte strings require symbols in order to be atomized.
|
|
// There is no dedicated section for 4 byte strings.
|
|
if (SMO.getType() == MachO::S_CSTRING_LITERALS)
|
|
return false;
|
|
|
|
if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
|
|
return false;
|
|
|
|
switch (SMO.getType()) {
|
|
default:
|
|
return true;
|
|
|
|
// These sections are atomized at the element boundaries without using
|
|
// symbols.
|
|
case MachO::S_4BYTE_LITERALS:
|
|
case MachO::S_8BYTE_LITERALS:
|
|
case MachO::S_16BYTE_LITERALS:
|
|
case MachO::S_LITERAL_POINTERS:
|
|
case MachO::S_NON_LAZY_SYMBOL_POINTERS:
|
|
case MachO::S_LAZY_SYMBOL_POINTERS:
|
|
case MachO::S_MOD_INIT_FUNC_POINTERS:
|
|
case MachO::S_MOD_TERM_FUNC_POINTERS:
|
|
case MachO::S_INTERPOSING:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
MCAsmInfoDarwin::MCAsmInfoDarwin() {
|
|
// Common settings for all Darwin targets.
|
|
// Syntax:
|
|
LinkerPrivateGlobalPrefix = "l";
|
|
HasSingleParameterDotFile = false;
|
|
HasSubsectionsViaSymbols = true;
|
|
|
|
AlignmentIsInBytes = false;
|
|
COMMDirectiveAlignmentIsInBytes = false;
|
|
LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
|
|
InlineAsmStart = " InlineAsm Start";
|
|
InlineAsmEnd = " InlineAsm End";
|
|
|
|
// Directives:
|
|
HasWeakDefDirective = true;
|
|
HasWeakDefCanBeHiddenDirective = true;
|
|
WeakRefDirective = "\t.weak_reference ";
|
|
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
|
|
HasMachoZeroFillDirective = true; // Uses .zerofill
|
|
HasMachoTBSSDirective = true; // Uses .tbss
|
|
HasStaticCtorDtorReferenceInStaticMode = true;
|
|
|
|
// FIXME: Change this once MC is the system assembler.
|
|
HasAggressiveSymbolFolding = false;
|
|
|
|
HiddenVisibilityAttr = MCSA_PrivateExtern;
|
|
HiddenDeclarationVisibilityAttr = MCSA_Invalid;
|
|
|
|
// Doesn't support protected visibility.
|
|
ProtectedVisibilityAttr = MCSA_Invalid;
|
|
|
|
HasDotTypeDotSizeDirective = false;
|
|
HasNoDeadStrip = true;
|
|
|
|
DwarfUsesRelocationsAcrossSections = false;
|
|
|
|
UseIntegratedAssembler = true;
|
|
SetDirectiveSuppressesReloc = true;
|
|
}
|