[XCOFF][AIX] Differentiate usage of label symbol and csect symbol
Summary:
We are using symbols to represent label and csect interchangeably before, and that could be a problem.
There are cases we would need to add storage mapping class to the symbol if that symbol is actually the name of a csect, but it's hard for us to figure out whether that symbol is a label or csect.
This patch intend to do the following:
1. Construct a QualName (A name include the storage mapping class)
MCSymbolXCOFF for every MCSectionXCOFF.
2. Keep a pointer to that QualName inside of MCSectionXCOFF.
3. Use that QualName whenever we need a symbol refers to that
MCSectionXCOFF.
4. Adapt the snowball effect from the above changes in
XCOFFObjectWriter.cpp.
Reviewers: xingxue, DiggerLin, sfertile, daltenty, hubert.reinterpretcast
Reviewed By: DiggerLin, daltenty
Subscribers: wuzish, nemanjai, mgorny, hiraditya, kbarton, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69633
2019-11-08 22:26:28 +08:00
|
|
|
//===-- llvm/BinaryFormat/XCOFF.cpp - The XCOFF file format -----*- C++/-*-===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/BinaryFormat/XCOFF.h"
|
2020-04-23 20:10:55 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
[XCOFF][AIX] Differentiate usage of label symbol and csect symbol
Summary:
We are using symbols to represent label and csect interchangeably before, and that could be a problem.
There are cases we would need to add storage mapping class to the symbol if that symbol is actually the name of a csect, but it's hard for us to figure out whether that symbol is a label or csect.
This patch intend to do the following:
1. Construct a QualName (A name include the storage mapping class)
MCSymbolXCOFF for every MCSectionXCOFF.
2. Keep a pointer to that QualName inside of MCSectionXCOFF.
3. Use that QualName whenever we need a symbol refers to that
MCSectionXCOFF.
4. Adapt the snowball effect from the above changes in
XCOFFObjectWriter.cpp.
Reviewers: xingxue, DiggerLin, sfertile, daltenty, hubert.reinterpretcast
Reviewed By: DiggerLin, daltenty
Subscribers: wuzish, nemanjai, mgorny, hiraditya, kbarton, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69633
2019-11-08 22:26:28 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2020-04-06 22:09:12 +08:00
|
|
|
#define SMC_CASE(A) \
|
|
|
|
case XCOFF::XMC_##A: \
|
|
|
|
return #A;
|
[XCOFF][AIX] Differentiate usage of label symbol and csect symbol
Summary:
We are using symbols to represent label and csect interchangeably before, and that could be a problem.
There are cases we would need to add storage mapping class to the symbol if that symbol is actually the name of a csect, but it's hard for us to figure out whether that symbol is a label or csect.
This patch intend to do the following:
1. Construct a QualName (A name include the storage mapping class)
MCSymbolXCOFF for every MCSectionXCOFF.
2. Keep a pointer to that QualName inside of MCSectionXCOFF.
3. Use that QualName whenever we need a symbol refers to that
MCSectionXCOFF.
4. Adapt the snowball effect from the above changes in
XCOFFObjectWriter.cpp.
Reviewers: xingxue, DiggerLin, sfertile, daltenty, hubert.reinterpretcast
Reviewed By: DiggerLin, daltenty
Subscribers: wuzish, nemanjai, mgorny, hiraditya, kbarton, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69633
2019-11-08 22:26:28 +08:00
|
|
|
StringRef XCOFF::getMappingClassString(XCOFF::StorageMappingClass SMC) {
|
|
|
|
switch (SMC) {
|
2020-04-06 22:09:12 +08:00
|
|
|
SMC_CASE(PR)
|
|
|
|
SMC_CASE(RO)
|
|
|
|
SMC_CASE(DB)
|
|
|
|
SMC_CASE(GL)
|
|
|
|
SMC_CASE(XO)
|
|
|
|
SMC_CASE(SV)
|
|
|
|
SMC_CASE(SV64)
|
|
|
|
SMC_CASE(SV3264)
|
|
|
|
SMC_CASE(TI)
|
|
|
|
SMC_CASE(TB)
|
|
|
|
SMC_CASE(RW)
|
|
|
|
SMC_CASE(TC0)
|
|
|
|
SMC_CASE(TC)
|
|
|
|
SMC_CASE(TD)
|
|
|
|
SMC_CASE(DS)
|
|
|
|
SMC_CASE(UA)
|
|
|
|
SMC_CASE(BS)
|
|
|
|
SMC_CASE(UC)
|
|
|
|
SMC_CASE(TL)
|
|
|
|
SMC_CASE(UL)
|
|
|
|
SMC_CASE(TE)
|
|
|
|
#undef SMC_CASE
|
[XCOFF][AIX] Differentiate usage of label symbol and csect symbol
Summary:
We are using symbols to represent label and csect interchangeably before, and that could be a problem.
There are cases we would need to add storage mapping class to the symbol if that symbol is actually the name of a csect, but it's hard for us to figure out whether that symbol is a label or csect.
This patch intend to do the following:
1. Construct a QualName (A name include the storage mapping class)
MCSymbolXCOFF for every MCSectionXCOFF.
2. Keep a pointer to that QualName inside of MCSectionXCOFF.
3. Use that QualName whenever we need a symbol refers to that
MCSectionXCOFF.
4. Adapt the snowball effect from the above changes in
XCOFFObjectWriter.cpp.
Reviewers: xingxue, DiggerLin, sfertile, daltenty, hubert.reinterpretcast
Reviewed By: DiggerLin, daltenty
Subscribers: wuzish, nemanjai, mgorny, hiraditya, kbarton, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69633
2019-11-08 22:26:28 +08:00
|
|
|
}
|
2020-04-06 22:09:12 +08:00
|
|
|
|
|
|
|
// TODO: need to add a test case for "Unknown" and other SMC.
|
|
|
|
return "Unknown";
|
[XCOFF][AIX] Differentiate usage of label symbol and csect symbol
Summary:
We are using symbols to represent label and csect interchangeably before, and that could be a problem.
There are cases we would need to add storage mapping class to the symbol if that symbol is actually the name of a csect, but it's hard for us to figure out whether that symbol is a label or csect.
This patch intend to do the following:
1. Construct a QualName (A name include the storage mapping class)
MCSymbolXCOFF for every MCSectionXCOFF.
2. Keep a pointer to that QualName inside of MCSectionXCOFF.
3. Use that QualName whenever we need a symbol refers to that
MCSectionXCOFF.
4. Adapt the snowball effect from the above changes in
XCOFFObjectWriter.cpp.
Reviewers: xingxue, DiggerLin, sfertile, daltenty, hubert.reinterpretcast
Reviewed By: DiggerLin, daltenty
Subscribers: wuzish, nemanjai, mgorny, hiraditya, kbarton, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69633
2019-11-08 22:26:28 +08:00
|
|
|
}
|
2020-03-28 00:02:27 +08:00
|
|
|
|
|
|
|
#define RELOC_CASE(A) \
|
|
|
|
case XCOFF::A: \
|
|
|
|
return #A;
|
|
|
|
StringRef XCOFF::getRelocationTypeString(XCOFF::RelocationType Type) {
|
|
|
|
switch (Type) {
|
|
|
|
RELOC_CASE(R_POS)
|
|
|
|
RELOC_CASE(R_RL)
|
|
|
|
RELOC_CASE(R_RLA)
|
|
|
|
RELOC_CASE(R_NEG)
|
|
|
|
RELOC_CASE(R_REL)
|
|
|
|
RELOC_CASE(R_TOC)
|
|
|
|
RELOC_CASE(R_TRL)
|
|
|
|
RELOC_CASE(R_TRLA)
|
|
|
|
RELOC_CASE(R_GL)
|
|
|
|
RELOC_CASE(R_TCL)
|
|
|
|
RELOC_CASE(R_REF)
|
|
|
|
RELOC_CASE(R_BA)
|
|
|
|
RELOC_CASE(R_BR)
|
|
|
|
RELOC_CASE(R_RBA)
|
|
|
|
RELOC_CASE(R_RBR)
|
|
|
|
RELOC_CASE(R_TLS)
|
|
|
|
RELOC_CASE(R_TLS_IE)
|
|
|
|
RELOC_CASE(R_TLS_LD)
|
|
|
|
RELOC_CASE(R_TLS_LE)
|
|
|
|
RELOC_CASE(R_TLSM)
|
|
|
|
RELOC_CASE(R_TLSML)
|
|
|
|
RELOC_CASE(R_TOCU)
|
|
|
|
RELOC_CASE(R_TOCL)
|
|
|
|
}
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
#undef RELOC_CASE
|