summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorin Papa <fpapa@google.com>2022-11-21 10:07:58 -0800
committerGopher Robot <gobot@golang.org>2023-02-03 04:37:17 +0000
commit9222a01e651f5968a1c66013f7094c265f4011e7 (patch)
tree62973a0d6bf02b05c6a77876c582695b8f3a1524
parent93f5335be96054bd3877cc88e1ddf7d60e5797ef (diff)
downloadgo-git-9222a01e651f5968a1c66013f7094c265f4011e7.tar.gz
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 <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r--api/next/56887.txt65
-rw-r--r--src/debug/elf/elf.go118
-rw-r--r--src/debug/elf/elf_test.go1
3 files changed, 184 insertions, 0 deletions
diff --git a/api/next/56887.txt b/api/next/56887.txt
new file mode 100644
index 0000000000..87788be4c8
--- /dev/null
+++ b/api/next/56887.txt
@@ -0,0 +1,65 @@
+pkg debug/elf, const DF_1_GLOBAL = 2 #56887
+pkg debug/elf, const DF_1_GLOBAL DynFlag1 #56887
+pkg debug/elf, const DF_1_DIRECT = 256 #56887
+pkg debug/elf, const DF_1_DIRECT DynFlag1 #56887
+pkg debug/elf, const DF_1_TRANS = 512 #56887
+pkg debug/elf, const DF_1_TRANS DynFlag1 #56887
+pkg debug/elf, const DF_1_NODUMP = 4096 #56887
+pkg debug/elf, const DF_1_NODUMP DynFlag1 #56887
+pkg debug/elf, const DF_1_CONFALT = 8192 #56887
+pkg debug/elf, const DF_1_CONFALT DynFlag1 #56887
+pkg debug/elf, const DF_1_DISPRELDNE = 32768 #56887
+pkg debug/elf, const DF_1_DISPRELDNE DynFlag1 #56887
+pkg debug/elf, const DF_1_DISPRELPND = 65536 #56887
+pkg debug/elf, const DF_1_DISPRELPND DynFlag1 #56887
+pkg debug/elf, const DF_1_IGNMULDEF = 262144 #56887
+pkg debug/elf, const DF_1_IGNMULDEF DynFlag1 #56887
+pkg debug/elf, const DF_1_NOKSYMS = 524288 #56887
+pkg debug/elf, const DF_1_NOKSYMS DynFlag1 #56887
+pkg debug/elf, const DF_1_NOHDR = 1048576 #56887
+pkg debug/elf, const DF_1_NOHDR DynFlag1 #56887
+pkg debug/elf, const DF_1_EDITED = 2097152 #56887
+pkg debug/elf, const DF_1_EDITED DynFlag1 #56887
+pkg debug/elf, const DF_1_NORELOC = 4194304 #56887
+pkg debug/elf, const DF_1_NORELOC DynFlag1 #56887
+pkg debug/elf, const DF_1_ENDFILTEE = 16384 #56887
+pkg debug/elf, const DF_1_ENDFILTEE DynFlag1 #56887
+pkg debug/elf, const DF_1_GLOBAUDIT = 16777216 #56887
+pkg debug/elf, const DF_1_GLOBAUDIT DynFlag1 #56887
+pkg debug/elf, const DF_1_GROUP = 4 #56887
+pkg debug/elf, const DF_1_GROUP DynFlag1 #56887
+pkg debug/elf, const DF_1_INITFIRST = 32 #56887
+pkg debug/elf, const DF_1_INITFIRST DynFlag1 #56887
+pkg debug/elf, const DF_1_INTERPOSE = 1024 #56887
+pkg debug/elf, const DF_1_INTERPOSE DynFlag1 #56887
+pkg debug/elf, const DF_1_KMOD = 268435456 #56887
+pkg debug/elf, const DF_1_KMOD DynFlag1 #56887
+pkg debug/elf, const DF_1_LOADFLTR = 16 #56887
+pkg debug/elf, const DF_1_LOADFLTR DynFlag1 #56887
+pkg debug/elf, const DF_1_NODEFLIB = 2048 #56887
+pkg debug/elf, const DF_1_NODEFLIB DynFlag1 #56887
+pkg debug/elf, const DF_1_NODELETE = 8 #56887
+pkg debug/elf, const DF_1_NODELETE DynFlag1 #56887
+pkg debug/elf, const DF_1_NODIRECT = 131072 #56887
+pkg debug/elf, const DF_1_NODIRECT DynFlag1 #56887
+pkg debug/elf, const DF_1_NOOPEN = 64 #56887
+pkg debug/elf, const DF_1_NOOPEN DynFlag1 #56887
+pkg debug/elf, const DF_1_NOW = 1 #56887
+pkg debug/elf, const DF_1_NOW DynFlag1 #56887
+pkg debug/elf, const DF_1_ORIGIN = 128 #56887
+pkg debug/elf, const DF_1_ORIGIN DynFlag1 #56887
+pkg debug/elf, const DF_1_PIE = 134217728 #56887
+pkg debug/elf, const DF_1_PIE DynFlag1 #56887
+pkg debug/elf, const DF_1_SINGLETON = 33554432 #56887
+pkg debug/elf, const DF_1_SINGLETON DynFlag1 #56887
+pkg debug/elf, const DF_1_STUB = 67108864 #56887
+pkg debug/elf, const DF_1_STUB DynFlag1 #56887
+pkg debug/elf, const DF_1_SYMINTPOSE = 8388608 #56887
+pkg debug/elf, const DF_1_SYMINTPOSE DynFlag1 #56887
+pkg debug/elf, const DF_1_WEAKFILTER = 536870912 #56887
+pkg debug/elf, const DF_1_WEAKFILTER DynFlag1 #56887
+pkg debug/elf, const DF_1_NOCOMMON = 1073741824 #56887
+pkg debug/elf, const DF_1_NOCOMMON DynFlag1 #56887
+pkg debug/elf, method (DynFlag1) GoString() string #56887
+pkg debug/elf, method (DynFlag1) String() string #56887
+pkg debug/elf, type DynFlag1 uint32 #56887
diff --git a/src/debug/elf/elf.go b/src/debug/elf/elf.go
index 02cda16510..ccb7e5a893 100644
--- a/src/debug/elf/elf.go
+++ b/src/debug/elf/elf.go
@@ -1107,6 +1107,124 @@ var dflagStrings = []intName{
func (i DynFlag) String() string { return flagName(uint32(i), dflagStrings, false) }
func (i DynFlag) GoString() string { return flagName(uint32(i), dflagStrings, true) }
+// DT_FLAGS_1 values.
+type DynFlag1 uint32
+
+const (
+ // Indicates that all relocations for this object must be processed before
+ // returning control to the program.
+ DF_1_NOW DynFlag1 = 0x00000001
+ // Unused.
+ DF_1_GLOBAL DynFlag1 = 0x00000002
+ // Indicates that the object is a member of a group.
+ DF_1_GROUP DynFlag1 = 0x00000004
+ // Indicates that the object cannot be deleted from a process.
+ DF_1_NODELETE DynFlag1 = 0x00000008
+ // Meaningful only for filters. Indicates that all associated filtees be
+ // processed immediately.
+ DF_1_LOADFLTR DynFlag1 = 0x00000010
+ // Indicates that this object's initialization section be run before any other
+ // objects loaded.
+ DF_1_INITFIRST DynFlag1 = 0x00000020
+ // Indicates that the object cannot be added to a running process with dlopen.
+ DF_1_NOOPEN DynFlag1 = 0x00000040
+ // Indicates the object requires $ORIGIN processing.
+ DF_1_ORIGIN DynFlag1 = 0x00000080
+ // Indicates that the object should use direct binding information.
+ DF_1_DIRECT DynFlag1 = 0x00000100
+ // Unused.
+ DF_1_TRANS DynFlag1 = 0x00000200
+ // Indicates that the objects symbol table is to interpose before all symbols
+ // except the primary load object, which is typically the executable.
+ DF_1_INTERPOSE DynFlag1 = 0x00000400
+ // Indicates that the search for dependencies of this object ignores any
+ // default library search paths.
+ DF_1_NODEFLIB DynFlag1 = 0x00000800
+ // Indicates that this object is not dumped by dldump. Candidates are objects
+ // with no relocations that might get included when generating alternative
+ // objects using.
+ DF_1_NODUMP DynFlag1 = 0x00001000
+ // Identifies this object as a configuration alternative object generated by
+ // crle. Triggers the runtime linker to search for a configuration file $ORIGIN/ld.config.app-name.
+ DF_1_CONFALT DynFlag1 = 0x00002000
+ // Meaningful only for filtees. Terminates a filters search for any
+ // further filtees.
+ DF_1_ENDFILTEE DynFlag1 = 0x00004000
+ // Indicates that this object has displacement relocations applied.
+ DF_1_DISPRELDNE DynFlag1 = 0x00008000
+ // Indicates that this object has displacement relocations pending.
+ DF_1_DISPRELPND DynFlag1 = 0x00010000
+ // Indicates that this object contains symbols that cannot be directly
+ // bound to.
+ DF_1_NODIRECT DynFlag1 = 0x00020000
+ // Reserved for internal use by the kernel runtime-linker.
+ DF_1_IGNMULDEF DynFlag1 = 0x00040000
+ // Reserved for internal use by the kernel runtime-linker.
+ DF_1_NOKSYMS DynFlag1 = 0x00080000
+ // Reserved for internal use by the kernel runtime-linker.
+ DF_1_NOHDR DynFlag1 = 0x00100000
+ // Indicates that this object has been edited or has been modified since the
+ // objects original construction by the link-editor.
+ DF_1_EDITED DynFlag1 = 0x00200000
+ // Reserved for internal use by the kernel runtime-linker.
+ DF_1_NORELOC DynFlag1 = 0x00400000
+ // Indicates that the object contains individual symbols that should interpose
+ // before all symbols except the primary load object, which is typically the
+ // executable.
+ DF_1_SYMINTPOSE DynFlag1 = 0x00800000
+ // Indicates that the executable requires global auditing.
+ DF_1_GLOBAUDIT DynFlag1 = 0x01000000
+ // Indicates that the object defines, or makes reference to singleton symbols.
+ DF_1_SINGLETON DynFlag1 = 0x02000000
+ // Indicates that the object is a stub.
+ DF_1_STUB DynFlag1 = 0x04000000
+ // Indicates that the object is a position-independent executable.
+ DF_1_PIE DynFlag1 = 0x08000000
+ // Indicates that the object is a kernel module.
+ DF_1_KMOD DynFlag1 = 0x10000000
+ // Indicates that the object is a weak standard filter.
+ DF_1_WEAKFILTER DynFlag1 = 0x20000000
+ // Unused.
+ DF_1_NOCOMMON DynFlag1 = 0x40000000
+)
+
+var dflag1Strings = []intName{
+ {0x00000001, "DF_1_NOW"},
+ {0x00000002, "DF_1_GLOBAL"},
+ {0x00000004, "DF_1_GROUP"},
+ {0x00000008, "DF_1_NODELETE"},
+ {0x00000010, "DF_1_LOADFLTR"},
+ {0x00000020, "DF_1_INITFIRST"},
+ {0x00000040, "DF_1_NOOPEN"},
+ {0x00000080, "DF_1_ORIGIN"},
+ {0x00000100, "DF_1_DIRECT"},
+ {0x00000200, "DF_1_TRANS"},
+ {0x00000400, "DF_1_INTERPOSE"},
+ {0x00000800, "DF_1_NODEFLIB"},
+ {0x00001000, "DF_1_NODUMP"},
+ {0x00002000, "DF_1_CONFALT"},
+ {0x00004000, "DF_1_ENDFILTEE"},
+ {0x00008000, "DF_1_DISPRELDNE"},
+ {0x00010000, "DF_1_DISPRELPND"},
+ {0x00020000, "DF_1_NODIRECT"},
+ {0x00040000, "DF_1_IGNMULDEF"},
+ {0x00080000, "DF_1_NOKSYMS"},
+ {0x00100000, "DF_1_NOHDR"},
+ {0x00200000, "DF_1_EDITED"},
+ {0x00400000, "DF_1_NORELOC"},
+ {0x00800000, "DF_1_SYMINTPOSE"},
+ {0x01000000, "DF_1_GLOBAUDIT"},
+ {0x02000000, "DF_1_SINGLETON"},
+ {0x04000000, "DF_1_STUB"},
+ {0x08000000, "DF_1_PIE"},
+ {0x10000000, "DF_1_KMOD"},
+ {0x20000000, "DF_1_WEAKFILTER"},
+ {0x40000000, "DF_1_NOCOMMON"},
+}
+
+func (i DynFlag1) String() string { return flagName(uint32(i), dflag1Strings, false) }
+func (i DynFlag1) GoString() string { return flagName(uint32(i), dflag1Strings, true) }
+
// NType values; used in core files.
type NType int
diff --git a/src/debug/elf/elf_test.go b/src/debug/elf/elf_test.go
index 814c6bd6cc..623a4147a7 100644
--- a/src/debug/elf/elf_test.go
+++ b/src/debug/elf/elf_test.go
@@ -25,6 +25,7 @@ var nameTests = []nameTest{
{PF_W + PF_R + 0x50, "PF_W+PF_R+0x50"},
{DT_SYMBOLIC, "DT_SYMBOLIC"},
{DF_BIND_NOW, "DF_BIND_NOW"},
+ {DF_1_PIE, "DF_1_PIE"},
{NT_FPREGSET, "NT_FPREGSET"},
{STB_GLOBAL, "STB_GLOBAL"},
{STT_COMMON, "STT_COMMON"},