2019-07-09 21:21:01 +02:00
|
|
|
//===- MCSectionXCOFF.h - XCOFF Machine Code Sections -----------*- 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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the MCSectionXCOFF class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCSECTIONXCOFF_H
|
|
|
|
#define LLVM_MC_MCSECTIONXCOFF_H
|
|
|
|
|
|
|
|
#include "llvm/BinaryFormat/XCOFF.h"
|
|
|
|
#include "llvm/MC/MCSection.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 15:26:28 +01:00
|
|
|
#include "llvm/MC/MCSymbolXCOFF.h"
|
2019-07-09 21:21:01 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
// This class represents an XCOFF `Control Section`, more commonly referred to
|
|
|
|
// as a csect. A csect represents the smallest possible unit of data/code which
|
2019-07-22 21:15:29 +02:00
|
|
|
// will be relocated as a single block. A csect can either be:
|
|
|
|
// 1) Initialized: The Type will be XTY_SD, and the symbols inside the csect
|
|
|
|
// will have a label definition representing their offset within the csect.
|
|
|
|
// 2) Uninitialized: The Type will be XTY_CM, it will contain a single symbol,
|
|
|
|
// and may not contain label definitions.
|
2019-07-30 17:37:01 +02:00
|
|
|
// 3) An external reference providing a symbol table entry for a symbol
|
|
|
|
// contained in another XCOFF object file. External reference csects are not
|
|
|
|
// implemented yet.
|
2019-07-09 21:21:01 +02:00
|
|
|
class MCSectionXCOFF final : public MCSection {
|
|
|
|
friend class MCContext;
|
|
|
|
|
|
|
|
XCOFF::StorageMappingClass MappingClass;
|
2019-07-22 21:15:29 +02:00
|
|
|
XCOFF::SymbolType Type;
|
2019-08-21 00:03:18 +02:00
|
|
|
XCOFF::StorageClass StorageClass;
|
[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 15:26:28 +01:00
|
|
|
MCSymbolXCOFF *const QualName;
|
2020-07-06 16:18:06 +02:00
|
|
|
StringRef SymbolTableName;
|
2020-05-11 20:43:07 +02:00
|
|
|
static constexpr unsigned DefaultAlignVal = 4;
|
2019-07-09 21:21:01 +02:00
|
|
|
|
2020-04-16 00:49:05 +02:00
|
|
|
MCSectionXCOFF(StringRef Name, XCOFF::StorageMappingClass SMC,
|
2019-08-21 00:03:18 +02:00
|
|
|
XCOFF::SymbolType ST, XCOFF::StorageClass SC, SectionKind K,
|
2020-07-06 16:18:06 +02:00
|
|
|
MCSymbolXCOFF *QualName, MCSymbol *Begin,
|
|
|
|
StringRef SymbolTableName)
|
2020-04-16 00:49:05 +02:00
|
|
|
: MCSection(SV_XCOFF, Name, K, Begin), MappingClass(SMC), Type(ST),
|
2020-07-06 16:18:06 +02:00
|
|
|
StorageClass(SC), QualName(QualName), SymbolTableName(SymbolTableName) {
|
2019-11-25 16:02:01 +01:00
|
|
|
assert((ST == XCOFF::XTY_SD || ST == XCOFF::XTY_CM || ST == XCOFF::XTY_ER) &&
|
2019-07-30 17:37:01 +02:00
|
|
|
"Invalid or unhandled type for csect.");
|
[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 15:26:28 +01:00
|
|
|
assert(QualName != nullptr && "QualName is needed.");
|
|
|
|
QualName->setStorageClass(SC);
|
2020-04-03 15:13:13 +02:00
|
|
|
QualName->setRepresentedCsect(this);
|
2020-05-11 20:43:07 +02:00
|
|
|
// A csect is 4 byte aligned by default, except for undefined symbol csects.
|
|
|
|
if (Type != XCOFF::XTY_ER)
|
|
|
|
setAlignment(Align(DefaultAlignVal));
|
2019-07-22 21:15:29 +02:00
|
|
|
}
|
2019-07-09 21:21:01 +02:00
|
|
|
|
2020-05-11 20:43:07 +02:00
|
|
|
void printCsectDirective(raw_ostream &OS) const;
|
|
|
|
|
2019-07-09 21:21:01 +02:00
|
|
|
public:
|
|
|
|
~MCSectionXCOFF();
|
|
|
|
|
|
|
|
static bool classof(const MCSection *S) {
|
|
|
|
return S->getVariant() == SV_XCOFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
XCOFF::StorageMappingClass getMappingClass() const { return MappingClass; }
|
[XCOFF] Output object text section header and symbol entry for program code.
This is remaining part of rG41ca91f2995b: [AIX][XCOFF] Output XCOFF
object text section header and symbol entry for rogram code.
SUMMARY:
Original form of this patch is provided by Stefan Pintillie.
1. The patch try to output program code section header , symbol entry for
program code (PR) and Instruction into the raw text section.
2. The patch include how to alignment and layout the CSection in the text
section.
3. The patch also reorganize the code , put some codes into a function.
(XCOFFObjectWriter::writeSymbolTableEntryForControlSection)
Additional: We can not add raw data of text section test in the patch, If want
to output raw text section data,it need a function description patch first.
Reviewers: hubert.reinterpretcast, sfertile, jasonliu, xingxue.
Subscribers: wuzish, nemanjai, hiraditya, MaskRay, jsjji.
Differential Revision: https://reviews.llvm.org/D66969
llvm-svn: 374923
2019-10-15 19:40:41 +02:00
|
|
|
XCOFF::StorageClass getStorageClass() const { return StorageClass; }
|
2019-07-22 21:15:29 +02:00
|
|
|
XCOFF::SymbolType getCSectType() const { return Type; }
|
[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 15:26:28 +01:00
|
|
|
MCSymbolXCOFF *getQualNameSymbol() const { return QualName; }
|
2019-07-09 21:21:01 +02:00
|
|
|
|
|
|
|
void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
|
|
|
|
raw_ostream &OS,
|
|
|
|
const MCExpr *Subsection) const override;
|
|
|
|
bool UseCodeAlign() const override;
|
|
|
|
bool isVirtualSection() const override;
|
2020-07-06 16:18:06 +02:00
|
|
|
StringRef getSymbolTableName() const { return SymbolTableName; }
|
2019-07-09 21:21:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|