-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[GOFF] Add writing of section symbols #133799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/redstar/goffwriter-2
Are you sure you want to change the base?
Changes from all commits
77c230f
bb71a07
a0a2a1f
18cd9eb
f2be856
3cf7324
686b628
c7fcda9
1ca5fdc
682f07b
5d522fd
74e804c
c541729
469206d
f859b78
7be8fa3
f358e40
83440e1
b6b261a
01549d4
4d7e8c5
1926203
adef64a
a4b425f
0b54967
7576e13
7803d02
5810c44
ba1223a
2f6babe
005bd75
7ba4c75
9f0aa12
4883fc3
1e4c700
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
//===- MCGOFFAttributes.h - Attributes of GOFF symbols --------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Defines the various attribute collections defining GOFF symbols. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_MC_MCGOFFATTRIBUTES_H | ||
#define LLVM_MC_MCGOFFATTRIBUTES_H | ||
|
||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/BinaryFormat/GOFF.h" | ||
#include <cstdint> | ||
|
||
namespace llvm { | ||
namespace GOFF { | ||
// An "External Symbol Definition" in the GOFF file has a type, and depending on | ||
// the type a different subset of the fields is used. | ||
// | ||
// Unlike other formats, a 2 dimensional structure is used to define the | ||
// location of data. For example, the equivalent of the ELF .text section is | ||
// made up of a Section Definition (SD) and a class (Element Definition; ED). | ||
// The name of the SD symbol depends on the application, while the class has the | ||
// predefined name C_CODE/C_CODE64 in AMODE31 and AMODE64 respectively. | ||
// | ||
// Data can be placed into this structure in 2 ways. First, the data (in a text | ||
// record) can be associated with an ED symbol. To refer to data, a Label | ||
// Definition (LD) is used to give an offset into the data a name. When binding, | ||
// the whole data is pulled into the resulting executable, and the addresses | ||
// given by the LD symbols are resolved. | ||
// | ||
// The alternative is to use a Part Definition (PR). In this case, the data (in | ||
// a text record) is associated with the part. When binding, only the data of | ||
// referenced PRs is pulled into the resulting binary. | ||
// | ||
// Both approaches are used, which means that the equivalent of a section in ELF | ||
// results in 3 GOFF symbols, either SD/ED/LD or SD/ED/PR. Moreover, certain | ||
// sections are fine with just defining SD/ED symbols. The SymbolMapper takes | ||
// care of all those details. | ||
|
||
// Attributes for SD symbols. | ||
struct SDAttr { | ||
GOFF::ESDTaskingBehavior TaskingBehavior = GOFF::ESD_TA_Unspecified; | ||
GOFF::ESDBindingScope BindingScope = GOFF::ESD_BSC_Unspecified; | ||
}; | ||
|
||
// Attributes for ED symbols. | ||
struct EDAttr { | ||
bool IsReadOnly = false; | ||
GOFF::ESDRmode Rmode; | ||
GOFF::ESDNameSpaceId NameSpace = GOFF::ESD_NS_NormalName; | ||
GOFF::ESDTextStyle TextStyle = GOFF::ESD_TS_ByteOriented; | ||
GOFF::ESDBindingAlgorithm BindAlgorithm = GOFF::ESD_BA_Concatenate; | ||
GOFF::ESDLoadingBehavior LoadBehavior = GOFF::ESD_LB_Initial; | ||
GOFF::ESDReserveQwords ReservedQwords = GOFF::ESD_RQ_0; | ||
GOFF::ESDAlignment Alignment = GOFF::ESD_ALIGN_Doubleword; | ||
uint8_t FillByteValue = 0; | ||
}; | ||
|
||
// Attributes for LD symbols. | ||
struct LDAttr { | ||
bool IsRenamable = false; | ||
GOFF::ESDExecutable Executable = GOFF::ESD_EXE_Unspecified; | ||
GOFF::ESDBindingStrength BindingStrength = GOFF::ESD_BST_Strong; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For LD (as opposed to ER), it seems "strong" is the only allowed value here. Again, if this is true, it doesn't make much sense to specify it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually needed for C++ inline functions etc. which can end up in several object files. Also for weak definitions, e.g.:
and
(example taken from a blog by @MaskRay) Another case were the documentation needs an update. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. This is not currently reflected in the HLASM output, however. How would one do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to ask for this. I see only WXTRN for weak externals in the HLASM documentation. |
||
GOFF::ESDLinkageType Linkage = GOFF::ESD_LT_XPLink; | ||
GOFF::ESDAmode Amode; | ||
GOFF::ESDBindingScope BindingScope = GOFF::ESD_BSC_Unspecified; | ||
}; | ||
|
||
// Attributes for PR symbols. | ||
struct PRAttr { | ||
bool IsRenamable = false; | ||
GOFF::ESDExecutable Executable = GOFF::ESD_EXE_Unspecified; | ||
GOFF::ESDLinkageType Linkage = GOFF::ESD_LT_XPLink; | ||
GOFF::ESDBindingScope BindingScope = GOFF::ESD_BSC_Unspecified; | ||
uint32_t SortKey = 0; | ||
}; | ||
|
||
// Class names and other values depending on AMODE64 or AMODE31, and other | ||
// environment properties. For now, only the 64 bit XPLINK case is defined. | ||
|
||
// GOFF classes. | ||
constexpr StringLiteral CLASS_CODE = "C_CODE64"; | ||
constexpr StringLiteral CLASS_WSA = "C_WSA64"; | ||
constexpr StringLiteral CLASS_DATA = "C_DATA64"; | ||
constexpr StringLiteral CLASS_PPA2 = "C_@@QPPA2"; | ||
|
||
// Addres and residency mode. | ||
constexpr GOFF::ESDAmode AMODE = GOFF::ESD_AMODE_64; | ||
constexpr GOFF::ESDRmode RMODE = GOFF::ESD_RMODE_64; | ||
|
||
// Linkage. | ||
constexpr GOFF::ESDLinkageType LINKAGE = GOFF::ESD_LT_XPLink; | ||
|
||
// Loadding behavior. | ||
constexpr GOFF::ESDLoadingBehavior LOADBEHAVIOR = GOFF::ESD_LB_Initial; | ||
|
||
} // namespace GOFF | ||
} // namespace llvm | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like I once knew the answer to this question but I have since forgotten...
What's up with this field? The documentation linked a few lines above say that field is reserved - does the documentation need an update, or can this be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For ED- and PR-type records, this field specifies the amount of space (in multiples of 16-byte quadwords) that the Binder will reserve at the origin of an element.
It's required, and the documentation needs an update.