Skip to content

Commit 9222a01

Browse files
florinpapagopherbot
authored andcommitted
debug/elf: add DT_FLAGS_1 constants
Add constants for all ELF dynamic flags (pertaining to DT_FLAGS_1). This will help, for example, determining whether an object is a position-independent executable (PIE). The constants are defined according to Table 15-10 in https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/linkers-libraries/dynamic-section.html. Fixes #56887 Change-Id: I6cd501af50d9dbcc2aa8a9a002e12c6fb6726761 Reviewed-on: https://go-review.googlesource.com/c/go/+/452496 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 93f5335 commit 9222a01

File tree

3 files changed

+184
-0
lines changed

3 files changed

+184
-0
lines changed

api/next/56887.txt

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
pkg debug/elf, const DF_1_GLOBAL = 2 #56887
2+
pkg debug/elf, const DF_1_GLOBAL DynFlag1 #56887
3+
pkg debug/elf, const DF_1_DIRECT = 256 #56887
4+
pkg debug/elf, const DF_1_DIRECT DynFlag1 #56887
5+
pkg debug/elf, const DF_1_TRANS = 512 #56887
6+
pkg debug/elf, const DF_1_TRANS DynFlag1 #56887
7+
pkg debug/elf, const DF_1_NODUMP = 4096 #56887
8+
pkg debug/elf, const DF_1_NODUMP DynFlag1 #56887
9+
pkg debug/elf, const DF_1_CONFALT = 8192 #56887
10+
pkg debug/elf, const DF_1_CONFALT DynFlag1 #56887
11+
pkg debug/elf, const DF_1_DISPRELDNE = 32768 #56887
12+
pkg debug/elf, const DF_1_DISPRELDNE DynFlag1 #56887
13+
pkg debug/elf, const DF_1_DISPRELPND = 65536 #56887
14+
pkg debug/elf, const DF_1_DISPRELPND DynFlag1 #56887
15+
pkg debug/elf, const DF_1_IGNMULDEF = 262144 #56887
16+
pkg debug/elf, const DF_1_IGNMULDEF DynFlag1 #56887
17+
pkg debug/elf, const DF_1_NOKSYMS = 524288 #56887
18+
pkg debug/elf, const DF_1_NOKSYMS DynFlag1 #56887
19+
pkg debug/elf, const DF_1_NOHDR = 1048576 #56887
20+
pkg debug/elf, const DF_1_NOHDR DynFlag1 #56887
21+
pkg debug/elf, const DF_1_EDITED = 2097152 #56887
22+
pkg debug/elf, const DF_1_EDITED DynFlag1 #56887
23+
pkg debug/elf, const DF_1_NORELOC = 4194304 #56887
24+
pkg debug/elf, const DF_1_NORELOC DynFlag1 #56887
25+
pkg debug/elf, const DF_1_ENDFILTEE = 16384 #56887
26+
pkg debug/elf, const DF_1_ENDFILTEE DynFlag1 #56887
27+
pkg debug/elf, const DF_1_GLOBAUDIT = 16777216 #56887
28+
pkg debug/elf, const DF_1_GLOBAUDIT DynFlag1 #56887
29+
pkg debug/elf, const DF_1_GROUP = 4 #56887
30+
pkg debug/elf, const DF_1_GROUP DynFlag1 #56887
31+
pkg debug/elf, const DF_1_INITFIRST = 32 #56887
32+
pkg debug/elf, const DF_1_INITFIRST DynFlag1 #56887
33+
pkg debug/elf, const DF_1_INTERPOSE = 1024 #56887
34+
pkg debug/elf, const DF_1_INTERPOSE DynFlag1 #56887
35+
pkg debug/elf, const DF_1_KMOD = 268435456 #56887
36+
pkg debug/elf, const DF_1_KMOD DynFlag1 #56887
37+
pkg debug/elf, const DF_1_LOADFLTR = 16 #56887
38+
pkg debug/elf, const DF_1_LOADFLTR DynFlag1 #56887
39+
pkg debug/elf, const DF_1_NODEFLIB = 2048 #56887
40+
pkg debug/elf, const DF_1_NODEFLIB DynFlag1 #56887
41+
pkg debug/elf, const DF_1_NODELETE = 8 #56887
42+
pkg debug/elf, const DF_1_NODELETE DynFlag1 #56887
43+
pkg debug/elf, const DF_1_NODIRECT = 131072 #56887
44+
pkg debug/elf, const DF_1_NODIRECT DynFlag1 #56887
45+
pkg debug/elf, const DF_1_NOOPEN = 64 #56887
46+
pkg debug/elf, const DF_1_NOOPEN DynFlag1 #56887
47+
pkg debug/elf, const DF_1_NOW = 1 #56887
48+
pkg debug/elf, const DF_1_NOW DynFlag1 #56887
49+
pkg debug/elf, const DF_1_ORIGIN = 128 #56887
50+
pkg debug/elf, const DF_1_ORIGIN DynFlag1 #56887
51+
pkg debug/elf, const DF_1_PIE = 134217728 #56887
52+
pkg debug/elf, const DF_1_PIE DynFlag1 #56887
53+
pkg debug/elf, const DF_1_SINGLETON = 33554432 #56887
54+
pkg debug/elf, const DF_1_SINGLETON DynFlag1 #56887
55+
pkg debug/elf, const DF_1_STUB = 67108864 #56887
56+
pkg debug/elf, const DF_1_STUB DynFlag1 #56887
57+
pkg debug/elf, const DF_1_SYMINTPOSE = 8388608 #56887
58+
pkg debug/elf, const DF_1_SYMINTPOSE DynFlag1 #56887
59+
pkg debug/elf, const DF_1_WEAKFILTER = 536870912 #56887
60+
pkg debug/elf, const DF_1_WEAKFILTER DynFlag1 #56887
61+
pkg debug/elf, const DF_1_NOCOMMON = 1073741824 #56887
62+
pkg debug/elf, const DF_1_NOCOMMON DynFlag1 #56887
63+
pkg debug/elf, method (DynFlag1) GoString() string #56887
64+
pkg debug/elf, method (DynFlag1) String() string #56887
65+
pkg debug/elf, type DynFlag1 uint32 #56887

src/debug/elf/elf.go

+118
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,124 @@ var dflagStrings = []intName{
11071107
func (i DynFlag) String() string { return flagName(uint32(i), dflagStrings, false) }
11081108
func (i DynFlag) GoString() string { return flagName(uint32(i), dflagStrings, true) }
11091109

1110+
// DT_FLAGS_1 values.
1111+
type DynFlag1 uint32
1112+
1113+
const (
1114+
// Indicates that all relocations for this object must be processed before
1115+
// returning control to the program.
1116+
DF_1_NOW DynFlag1 = 0x00000001
1117+
// Unused.
1118+
DF_1_GLOBAL DynFlag1 = 0x00000002
1119+
// Indicates that the object is a member of a group.
1120+
DF_1_GROUP DynFlag1 = 0x00000004
1121+
// Indicates that the object cannot be deleted from a process.
1122+
DF_1_NODELETE DynFlag1 = 0x00000008
1123+
// Meaningful only for filters. Indicates that all associated filtees be
1124+
// processed immediately.
1125+
DF_1_LOADFLTR DynFlag1 = 0x00000010
1126+
// Indicates that this object's initialization section be run before any other
1127+
// objects loaded.
1128+
DF_1_INITFIRST DynFlag1 = 0x00000020
1129+
// Indicates that the object cannot be added to a running process with dlopen.
1130+
DF_1_NOOPEN DynFlag1 = 0x00000040
1131+
// Indicates the object requires $ORIGIN processing.
1132+
DF_1_ORIGIN DynFlag1 = 0x00000080
1133+
// Indicates that the object should use direct binding information.
1134+
DF_1_DIRECT DynFlag1 = 0x00000100
1135+
// Unused.
1136+
DF_1_TRANS DynFlag1 = 0x00000200
1137+
// Indicates that the objects symbol table is to interpose before all symbols
1138+
// except the primary load object, which is typically the executable.
1139+
DF_1_INTERPOSE DynFlag1 = 0x00000400
1140+
// Indicates that the search for dependencies of this object ignores any
1141+
// default library search paths.
1142+
DF_1_NODEFLIB DynFlag1 = 0x00000800
1143+
// Indicates that this object is not dumped by dldump. Candidates are objects
1144+
// with no relocations that might get included when generating alternative
1145+
// objects using.
1146+
DF_1_NODUMP DynFlag1 = 0x00001000
1147+
// Identifies this object as a configuration alternative object generated by
1148+
// crle. Triggers the runtime linker to search for a configuration file $ORIGIN/ld.config.app-name.
1149+
DF_1_CONFALT DynFlag1 = 0x00002000
1150+
// Meaningful only for filtees. Terminates a filters search for any
1151+
// further filtees.
1152+
DF_1_ENDFILTEE DynFlag1 = 0x00004000
1153+
// Indicates that this object has displacement relocations applied.
1154+
DF_1_DISPRELDNE DynFlag1 = 0x00008000
1155+
// Indicates that this object has displacement relocations pending.
1156+
DF_1_DISPRELPND DynFlag1 = 0x00010000
1157+
// Indicates that this object contains symbols that cannot be directly
1158+
// bound to.
1159+
DF_1_NODIRECT DynFlag1 = 0x00020000
1160+
// Reserved for internal use by the kernel runtime-linker.
1161+
DF_1_IGNMULDEF DynFlag1 = 0x00040000
1162+
// Reserved for internal use by the kernel runtime-linker.
1163+
DF_1_NOKSYMS DynFlag1 = 0x00080000
1164+
// Reserved for internal use by the kernel runtime-linker.
1165+
DF_1_NOHDR DynFlag1 = 0x00100000
1166+
// Indicates that this object has been edited or has been modified since the
1167+
// objects original construction by the link-editor.
1168+
DF_1_EDITED DynFlag1 = 0x00200000
1169+
// Reserved for internal use by the kernel runtime-linker.
1170+
DF_1_NORELOC DynFlag1 = 0x00400000
1171+
// Indicates that the object contains individual symbols that should interpose
1172+
// before all symbols except the primary load object, which is typically the
1173+
// executable.
1174+
DF_1_SYMINTPOSE DynFlag1 = 0x00800000
1175+
// Indicates that the executable requires global auditing.
1176+
DF_1_GLOBAUDIT DynFlag1 = 0x01000000
1177+
// Indicates that the object defines, or makes reference to singleton symbols.
1178+
DF_1_SINGLETON DynFlag1 = 0x02000000
1179+
// Indicates that the object is a stub.
1180+
DF_1_STUB DynFlag1 = 0x04000000
1181+
// Indicates that the object is a position-independent executable.
1182+
DF_1_PIE DynFlag1 = 0x08000000
1183+
// Indicates that the object is a kernel module.
1184+
DF_1_KMOD DynFlag1 = 0x10000000
1185+
// Indicates that the object is a weak standard filter.
1186+
DF_1_WEAKFILTER DynFlag1 = 0x20000000
1187+
// Unused.
1188+
DF_1_NOCOMMON DynFlag1 = 0x40000000
1189+
)
1190+
1191+
var dflag1Strings = []intName{
1192+
{0x00000001, "DF_1_NOW"},
1193+
{0x00000002, "DF_1_GLOBAL"},
1194+
{0x00000004, "DF_1_GROUP"},
1195+
{0x00000008, "DF_1_NODELETE"},
1196+
{0x00000010, "DF_1_LOADFLTR"},
1197+
{0x00000020, "DF_1_INITFIRST"},
1198+
{0x00000040, "DF_1_NOOPEN"},
1199+
{0x00000080, "DF_1_ORIGIN"},
1200+
{0x00000100, "DF_1_DIRECT"},
1201+
{0x00000200, "DF_1_TRANS"},
1202+
{0x00000400, "DF_1_INTERPOSE"},
1203+
{0x00000800, "DF_1_NODEFLIB"},
1204+
{0x00001000, "DF_1_NODUMP"},
1205+
{0x00002000, "DF_1_CONFALT"},
1206+
{0x00004000, "DF_1_ENDFILTEE"},
1207+
{0x00008000, "DF_1_DISPRELDNE"},
1208+
{0x00010000, "DF_1_DISPRELPND"},
1209+
{0x00020000, "DF_1_NODIRECT"},
1210+
{0x00040000, "DF_1_IGNMULDEF"},
1211+
{0x00080000, "DF_1_NOKSYMS"},
1212+
{0x00100000, "DF_1_NOHDR"},
1213+
{0x00200000, "DF_1_EDITED"},
1214+
{0x00400000, "DF_1_NORELOC"},
1215+
{0x00800000, "DF_1_SYMINTPOSE"},
1216+
{0x01000000, "DF_1_GLOBAUDIT"},
1217+
{0x02000000, "DF_1_SINGLETON"},
1218+
{0x04000000, "DF_1_STUB"},
1219+
{0x08000000, "DF_1_PIE"},
1220+
{0x10000000, "DF_1_KMOD"},
1221+
{0x20000000, "DF_1_WEAKFILTER"},
1222+
{0x40000000, "DF_1_NOCOMMON"},
1223+
}
1224+
1225+
func (i DynFlag1) String() string { return flagName(uint32(i), dflag1Strings, false) }
1226+
func (i DynFlag1) GoString() string { return flagName(uint32(i), dflag1Strings, true) }
1227+
11101228
// NType values; used in core files.
11111229
type NType int
11121230

src/debug/elf/elf_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var nameTests = []nameTest{
2525
{PF_W + PF_R + 0x50, "PF_W+PF_R+0x50"},
2626
{DT_SYMBOLIC, "DT_SYMBOLIC"},
2727
{DF_BIND_NOW, "DF_BIND_NOW"},
28+
{DF_1_PIE, "DF_1_PIE"},
2829
{NT_FPREGSET, "NT_FPREGSET"},
2930
{STB_GLOBAL, "STB_GLOBAL"},
3031
{STT_COMMON, "STT_COMMON"},

0 commit comments

Comments
 (0)