1 //===- MCGOFFAttributes.h - Attributes of GOFF symbols --------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Defines the various attribute collections defining GOFF symbols. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_MC_MCGOFFATTRIBUTES_H 14 #define LLVM_MC_MCGOFFATTRIBUTES_H 15 16 #include "llvm/ADT/StringRef.h" 17 #include "llvm/BinaryFormat/GOFF.h" 18 #include <cstdint> 19 20 namespace llvm { 21 namespace GOFF { 22 // An "External Symbol Definition" in the GOFF file has a type, and depending on 23 // the type a different subset of the fields is used. 24 // 25 // Unlike other formats, a 2 dimensional structure is used to define the 26 // location of data. For example, the equivalent of the ELF .text section is 27 // made up of a Section Definition (SD) and a class (Element Definition; ED). 28 // The name of the SD symbol depends on the application, while the class has the 29 // predefined name C_CODE/C_CODE64 in AMODE31 and AMODE64 respectively. 30 // 31 // Data can be placed into this structure in 2 ways. First, the data (in a text 32 // record) can be associated with an ED symbol. To refer to data, a Label 33 // Definition (LD) is used to give an offset into the data a name. When binding, 34 // the whole data is pulled into the resulting executable, and the addresses 35 // given by the LD symbols are resolved. 36 // 37 // The alternative is to use a Part Definition (PR). In this case, the data (in 38 // a text record) is associated with the part. When binding, only the data of 39 // referenced PRs is pulled into the resulting binary. 40 // 41 // Both approaches are used. SD, ED, and PR elements are modelled by nested 42 // MCSectionGOFF instances, while LD elements are associated with MCSymbolGOFF 43 // instances. 44 45 // Attributes for SD symbols. 46 struct SDAttr { 47 GOFF::ESDTaskingBehavior TaskingBehavior = GOFF::ESD_TA_Unspecified; 48 GOFF::ESDBindingScope BindingScope = GOFF::ESD_BSC_Unspecified; 49 }; 50 51 // Attributes for ED symbols. 52 struct EDAttr { 53 bool IsReadOnly = false; 54 GOFF::ESDRmode Rmode; 55 GOFF::ESDNameSpaceId NameSpace = GOFF::ESD_NS_NormalName; 56 GOFF::ESDTextStyle TextStyle = GOFF::ESD_TS_ByteOriented; 57 GOFF::ESDBindingAlgorithm BindAlgorithm = GOFF::ESD_BA_Concatenate; 58 GOFF::ESDLoadingBehavior LoadBehavior = GOFF::ESD_LB_Initial; 59 GOFF::ESDReserveQwords ReservedQwords = GOFF::ESD_RQ_0; 60 GOFF::ESDAlignment Alignment = GOFF::ESD_ALIGN_Doubleword; 61 uint8_t FillByteValue = 0; 62 }; 63 64 // Attributes for LD symbols. 65 struct LDAttr { 66 bool IsRenamable = false; 67 GOFF::ESDExecutable Executable = GOFF::ESD_EXE_Unspecified; 68 GOFF::ESDBindingStrength BindingStrength = GOFF::ESD_BST_Strong; 69 GOFF::ESDLinkageType Linkage = GOFF::ESD_LT_XPLink; 70 GOFF::ESDAmode Amode; 71 GOFF::ESDBindingScope BindingScope = GOFF::ESD_BSC_Unspecified; 72 }; 73 74 // Attributes for PR symbols. 75 struct PRAttr { 76 bool IsRenamable = false; 77 GOFF::ESDExecutable Executable = GOFF::ESD_EXE_Unspecified; 78 GOFF::ESDLinkageType Linkage = GOFF::ESD_LT_XPLink; 79 GOFF::ESDBindingScope BindingScope = GOFF::ESD_BSC_Unspecified; 80 uint32_t SortKey = 0; 81 }; 82 83 // Predefined GOFF class names. 84 constexpr StringLiteral CLASS_CODE = "C_CODE64"; 85 constexpr StringLiteral CLASS_WSA = "C_WSA64"; 86 constexpr StringLiteral CLASS_DATA = "C_DATA64"; 87 constexpr StringLiteral CLASS_PPA2 = "C_@@QPPA2"; 88 89 } // namespace GOFF 90 } // namespace llvm 91 92 #endif 93