debug/elf: add many PT_ and DT_ constants

Change-Id: Icbb5a0f0ff4aa0a425aa4a15477da7bd0d58339c
Reviewed-on: https://go-review.googlesource.com/c/go/+/255138
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/src/debug/elf/elf.go b/src/debug/elf/elf.go
index 96a67ce..2b777ea 100644
--- a/src/debug/elf/elf.go
+++ b/src/debug/elf/elf.go
@@ -745,18 +745,51 @@
 type ProgType int
 
 const (
-	PT_NULL    ProgType = 0          /* Unused entry. */
-	PT_LOAD    ProgType = 1          /* Loadable segment. */
-	PT_DYNAMIC ProgType = 2          /* Dynamic linking information segment. */
-	PT_INTERP  ProgType = 3          /* Pathname of interpreter. */
-	PT_NOTE    ProgType = 4          /* Auxiliary information. */
-	PT_SHLIB   ProgType = 5          /* Reserved (not used). */
-	PT_PHDR    ProgType = 6          /* Location of program header itself. */
-	PT_TLS     ProgType = 7          /* Thread local storage segment */
-	PT_LOOS    ProgType = 0x60000000 /* First OS-specific. */
-	PT_HIOS    ProgType = 0x6fffffff /* Last OS-specific. */
-	PT_LOPROC  ProgType = 0x70000000 /* First processor-specific type. */
-	PT_HIPROC  ProgType = 0x7fffffff /* Last processor-specific type. */
+	PT_NULL    ProgType = 0 /* Unused entry. */
+	PT_LOAD    ProgType = 1 /* Loadable segment. */
+	PT_DYNAMIC ProgType = 2 /* Dynamic linking information segment. */
+	PT_INTERP  ProgType = 3 /* Pathname of interpreter. */
+	PT_NOTE    ProgType = 4 /* Auxiliary information. */
+	PT_SHLIB   ProgType = 5 /* Reserved (not used). */
+	PT_PHDR    ProgType = 6 /* Location of program header itself. */
+	PT_TLS     ProgType = 7 /* Thread local storage segment */
+
+	PT_LOOS ProgType = 0x60000000 /* First OS-specific. */
+
+	PT_GNU_EH_FRAME ProgType = 0x6474e550 /* Frame unwind information */
+	PT_GNU_STACK    ProgType = 0x6474e551 /* Stack flags */
+	PT_GNU_RELRO    ProgType = 0x6474e552 /* Read only after relocs */
+	PT_GNU_PROPERTY ProgType = 0x6474e553 /* GNU property */
+	PT_GNU_MBIND_LO ProgType = 0x6474e555 /* Mbind segments start */
+	PT_GNU_MBIND_HI ProgType = 0x6474f554 /* Mbind segments finish */
+
+	PT_PAX_FLAGS ProgType = 0x65041580 /* PAX flags */
+
+	PT_OPENBSD_RANDOMIZE ProgType = 0x65a3dbe6 /* Random data */
+	PT_OPENBSD_WXNEEDED  ProgType = 0x65a3dbe7 /* W^X violations */
+	PT_OPENBSD_BOOTDATA  ProgType = 0x65a41be6 /* Boot arguments */
+
+	PT_SUNW_EH_FRAME ProgType = 0x6474e550 /* Frame unwind information */
+	PT_SUNWSTACK     ProgType = 0x6ffffffb /* Stack segment */
+
+	PT_HIOS ProgType = 0x6fffffff /* Last OS-specific. */
+
+	PT_LOPROC ProgType = 0x70000000 /* First processor-specific type. */
+
+	PT_ARM_ARCHEXT ProgType = 0x70000000 /* Architecture compatibility */
+	PT_ARM_EXIDX   ProgType = 0x70000001 /* Exception unwind tables */
+
+	PT_AARCH64_ARCHEXT ProgType = 0x70000000 /* Architecture compatibility */
+	PT_AARCH64_UNWIND  ProgType = 0x70000001 /* Exception unwind tables */
+
+	PT_MIPS_REGINFO  ProgType = 0x70000000 /* Register usage */
+	PT_MIPS_RTPROC   ProgType = 0x70000001 /* Runtime procedures */
+	PT_MIPS_OPTIONS  ProgType = 0x70000002 /* Options */
+	PT_MIPS_ABIFLAGS ProgType = 0x70000003 /* ABI flags */
+
+	PT_S390_PGSTE ProgType = 0x70000000 /* 4k page table size */
+
+	PT_HIPROC ProgType = 0x7fffffff /* Last processor-specific type. */
 )
 
 var ptStrings = []intName{
@@ -769,8 +802,19 @@
 	{6, "PT_PHDR"},
 	{7, "PT_TLS"},
 	{0x60000000, "PT_LOOS"},
+	{0x6474e550, "PT_GNU_EH_FRAME"},
+	{0x6474e551, "PT_GNU_STACK"},
+	{0x6474e552, "PT_GNU_RELRO"},
+	{0x6474e553, "PT_GNU_PROPERTY"},
+	{0x65041580, "PT_PAX_FLAGS"},
+	{0x65a3dbe6, "PT_OPENBSD_RANDOMIZE"},
+	{0x65a3dbe7, "PT_OPENBSD_WXNEEDED"},
+	{0x65a41be6, "PT_OPENBSD_BOOTDATA"},
+	{0x6ffffffb, "PT_SUNWSTACK"},
 	{0x6fffffff, "PT_HIOS"},
 	{0x70000000, "PT_LOPROC"},
+	// We don't list the processor-dependent ProgTypes,
+	// as the values overlap.
 	{0x7fffffff, "PT_HIPROC"},
 }
 
@@ -837,15 +881,114 @@
 	   the interpretation of the d_un union
 	   as follows: even == 'd_ptr', even == 'd_val'
 	   or none */
-	DT_PREINIT_ARRAY   DynTag = 32         /* Address of the array of pointers to pre-initialization functions. */
-	DT_PREINIT_ARRAYSZ DynTag = 33         /* Size in bytes of the array of pre-initialization functions. */
-	DT_LOOS            DynTag = 0x6000000d /* First OS-specific */
-	DT_HIOS            DynTag = 0x6ffff000 /* Last OS-specific */
-	DT_VERSYM          DynTag = 0x6ffffff0
-	DT_VERNEED         DynTag = 0x6ffffffe
-	DT_VERNEEDNUM      DynTag = 0x6fffffff
-	DT_LOPROC          DynTag = 0x70000000 /* First processor-specific type. */
-	DT_HIPROC          DynTag = 0x7fffffff /* Last processor-specific type. */
+	DT_PREINIT_ARRAY   DynTag = 32 /* Address of the array of pointers to pre-initialization functions. */
+	DT_PREINIT_ARRAYSZ DynTag = 33 /* Size in bytes of the array of pre-initialization functions. */
+	DT_SYMTAB_SHNDX    DynTag = 34 /* Address of SHT_SYMTAB_SHNDX section. */
+
+	DT_LOOS DynTag = 0x6000000d /* First OS-specific */
+	DT_HIOS DynTag = 0x6ffff000 /* Last OS-specific */
+
+	DT_VALRNGLO       DynTag = 0x6ffffd00
+	DT_GNU_PRELINKED  DynTag = 0x6ffffdf5
+	DT_GNU_CONFLICTSZ DynTag = 0x6ffffdf6
+	DT_GNU_LIBLISTSZ  DynTag = 0x6ffffdf7
+	DT_CHECKSUM       DynTag = 0x6ffffdf8
+	DT_PLTPADSZ       DynTag = 0x6ffffdf9
+	DT_MOVEENT        DynTag = 0x6ffffdfa
+	DT_MOVESZ         DynTag = 0x6ffffdfb
+	DT_FEATURE        DynTag = 0x6ffffdfc
+	DT_POSFLAG_1      DynTag = 0x6ffffdfd
+	DT_SYMINSZ        DynTag = 0x6ffffdfe
+	DT_SYMINENT       DynTag = 0x6ffffdff
+	DT_VALRNGHI       DynTag = 0x6ffffdff
+
+	DT_ADDRRNGLO    DynTag = 0x6ffffe00
+	DT_GNU_HASH     DynTag = 0x6ffffef5
+	DT_TLSDESC_PLT  DynTag = 0x6ffffef6
+	DT_TLSDESC_GOT  DynTag = 0x6ffffef7
+	DT_GNU_CONFLICT DynTag = 0x6ffffef8
+	DT_GNU_LIBLIST  DynTag = 0x6ffffef9
+	DT_CONFIG       DynTag = 0x6ffffefa
+	DT_DEPAUDIT     DynTag = 0x6ffffefb
+	DT_AUDIT        DynTag = 0x6ffffefc
+	DT_PLTPAD       DynTag = 0x6ffffefd
+	DT_MOVETAB      DynTag = 0x6ffffefe
+	DT_SYMINFO      DynTag = 0x6ffffeff
+	DT_ADDRRNGHI    DynTag = 0x6ffffeff
+
+	DT_VERSYM     DynTag = 0x6ffffff0
+	DT_RELACOUNT  DynTag = 0x6ffffff9
+	DT_RELCOUNT   DynTag = 0x6ffffffa
+	DT_FLAGS_1    DynTag = 0x6ffffffb
+	DT_VERDEF     DynTag = 0x6ffffffc
+	DT_VERDEFNUM  DynTag = 0x6ffffffd
+	DT_VERNEED    DynTag = 0x6ffffffe
+	DT_VERNEEDNUM DynTag = 0x6fffffff
+
+	DT_LOPROC DynTag = 0x70000000 /* First processor-specific type. */
+
+	DT_MIPS_RLD_VERSION           DynTag = 0x70000001
+	DT_MIPS_TIME_STAMP            DynTag = 0x70000002
+	DT_MIPS_ICHECKSUM             DynTag = 0x70000003
+	DT_MIPS_IVERSION              DynTag = 0x70000004
+	DT_MIPS_FLAGS                 DynTag = 0x70000005
+	DT_MIPS_BASE_ADDRESS          DynTag = 0x70000006
+	DT_MIPS_MSYM                  DynTag = 0x70000007
+	DT_MIPS_CONFLICT              DynTag = 0x70000008
+	DT_MIPS_LIBLIST               DynTag = 0x70000009
+	DT_MIPS_LOCAL_GOTNO           DynTag = 0x7000000a
+	DT_MIPS_CONFLICTNO            DynTag = 0x7000000b
+	DT_MIPS_LIBLISTNO             DynTag = 0x70000010
+	DT_MIPS_SYMTABNO              DynTag = 0x70000011
+	DT_MIPS_UNREFEXTNO            DynTag = 0x70000012
+	DT_MIPS_GOTSYM                DynTag = 0x70000013
+	DT_MIPS_HIPAGENO              DynTag = 0x70000014
+	DT_MIPS_RLD_MAP               DynTag = 0x70000016
+	DT_MIPS_DELTA_CLASS           DynTag = 0x70000017
+	DT_MIPS_DELTA_CLASS_NO        DynTag = 0x70000018
+	DT_MIPS_DELTA_INSTANCE        DynTag = 0x70000019
+	DT_MIPS_DELTA_INSTANCE_NO     DynTag = 0x7000001a
+	DT_MIPS_DELTA_RELOC           DynTag = 0x7000001b
+	DT_MIPS_DELTA_RELOC_NO        DynTag = 0x7000001c
+	DT_MIPS_DELTA_SYM             DynTag = 0x7000001d
+	DT_MIPS_DELTA_SYM_NO          DynTag = 0x7000001e
+	DT_MIPS_DELTA_CLASSSYM        DynTag = 0x70000020
+	DT_MIPS_DELTA_CLASSSYM_NO     DynTag = 0x70000021
+	DT_MIPS_CXX_FLAGS             DynTag = 0x70000022
+	DT_MIPS_PIXIE_INIT            DynTag = 0x70000023
+	DT_MIPS_SYMBOL_LIB            DynTag = 0x70000024
+	DT_MIPS_LOCALPAGE_GOTIDX      DynTag = 0x70000025
+	DT_MIPS_LOCAL_GOTIDX          DynTag = 0x70000026
+	DT_MIPS_HIDDEN_GOTIDX         DynTag = 0x70000027
+	DT_MIPS_PROTECTED_GOTIDX      DynTag = 0x70000028
+	DT_MIPS_OPTIONS               DynTag = 0x70000029
+	DT_MIPS_INTERFACE             DynTag = 0x7000002a
+	DT_MIPS_DYNSTR_ALIGN          DynTag = 0x7000002b
+	DT_MIPS_INTERFACE_SIZE        DynTag = 0x7000002c
+	DT_MIPS_RLD_TEXT_RESOLVE_ADDR DynTag = 0x7000002d
+	DT_MIPS_PERF_SUFFIX           DynTag = 0x7000002e
+	DT_MIPS_COMPACT_SIZE          DynTag = 0x7000002f
+	DT_MIPS_GP_VALUE              DynTag = 0x70000030
+	DT_MIPS_AUX_DYNAMIC           DynTag = 0x70000031
+	DT_MIPS_PLTGOT                DynTag = 0x70000032
+	DT_MIPS_RWPLT                 DynTag = 0x70000034
+	DT_MIPS_RLD_MAP_REL           DynTag = 0x70000035
+
+	DT_PPC_GOT DynTag = 0x70000000
+	DT_PPC_OPT DynTag = 0x70000001
+
+	DT_PPC64_GLINK DynTag = 0x70000000
+	DT_PPC64_OPD   DynTag = 0x70000001
+	DT_PPC64_OPDSZ DynTag = 0x70000002
+	DT_PPC64_OPT   DynTag = 0x70000003
+
+	DT_SPARC_REGISTER DynTag = 0x70000001
+
+	DT_AUXILIARY DynTag = 0x7ffffffd
+	DT_USED      DynTag = 0x7ffffffe
+	DT_FILTER    DynTag = 0x7fffffff
+
+	DT_HIPROC DynTag = 0x7fffffff /* Last processor-specific type. */
 )
 
 var dtStrings = []intName{
@@ -883,13 +1026,49 @@
 	{32, "DT_ENCODING"},
 	{32, "DT_PREINIT_ARRAY"},
 	{33, "DT_PREINIT_ARRAYSZ"},
+	{34, "DT_SYMTAB_SHNDX"},
 	{0x6000000d, "DT_LOOS"},
 	{0x6ffff000, "DT_HIOS"},
+	{0x6ffffd00, "DT_VALRNGLO"},
+	{0x6ffffdf5, "DT_GNU_PRELINKED"},
+	{0x6ffffdf6, "DT_GNU_CONFLICTSZ"},
+	{0x6ffffdf7, "DT_GNU_LIBLISTSZ"},
+	{0x6ffffdf8, "DT_CHECKSUM"},
+	{0x6ffffdf9, "DT_PLTPADSZ"},
+	{0x6ffffdfa, "DT_MOVEENT"},
+	{0x6ffffdfb, "DT_MOVESZ"},
+	{0x6ffffdfc, "DT_FEATURE"},
+	{0x6ffffdfd, "DT_POSFLAG_1"},
+	{0x6ffffdfe, "DT_SYMINSZ"},
+	{0x6ffffdff, "DT_SYMINENT"},
+	{0x6ffffdff, "DT_VALRNGHI"},
+	{0x6ffffe00, "DT_ADDRRNGLO"},
+	{0x6ffffef5, "DT_GNU_HASH"},
+	{0x6ffffef6, "DT_TLSDESC_PLT"},
+	{0x6ffffef7, "DT_TLSDESC_GOT"},
+	{0x6ffffef8, "DT_GNU_CONFLICT"},
+	{0x6ffffef9, "DT_GNU_LIBLIST"},
+	{0x6ffffefa, "DT_CONFIG"},
+	{0x6ffffefb, "DT_DEPAUDIT"},
+	{0x6ffffefc, "DT_AUDIT"},
+	{0x6ffffefd, "DT_PLTPAD"},
+	{0x6ffffefe, "DT_MOVETAB"},
+	{0x6ffffeff, "DT_SYMINFO"},
+	{0x6ffffeff, "DT_ADDRRNGHI"},
 	{0x6ffffff0, "DT_VERSYM"},
+	{0x6ffffff9, "DT_RELACOUNT"},
+	{0x6ffffffa, "DT_RELCOUNT"},
+	{0x6ffffffb, "DT_FLAGS_1"},
+	{0x6ffffffc, "DT_VERDEF"},
+	{0x6ffffffd, "DT_VERDEFNUM"},
 	{0x6ffffffe, "DT_VERNEED"},
 	{0x6fffffff, "DT_VERNEEDNUM"},
 	{0x70000000, "DT_LOPROC"},
-	{0x7fffffff, "DT_HIPROC"},
+	// We don't list the processor-dependent DynTags,
+	// as the values overlap.
+	{0x7ffffffd, "DT_AUXILIARY"},
+	{0x7ffffffe, "DT_USED"},
+	{0x7fffffff, "DT_FILTER"},
 }
 
 func (i DynTag) String() string   { return stringName(uint32(i), dtStrings, false) }