This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[BFD PATCH] grok NT_AUXV note in ELF core files
- From: Roland McGrath <roland at redhat dot com>
- To: binutils at sources dot redhat dot com
- Cc: gdb-patches at sources dot redhat dot com
- Date: Mon, 19 May 2003 14:46:56 -0700
- Subject: [BFD PATCH] grok NT_AUXV note in ELF core files
This patch makes BFD reading of ELF core files fake a section called
".auxv" for an NT_AUXV note, similar to the fake ".reg" section make for
the note containing register data. It also adds data structures to
include/elf/ for interpreting the contents of such sections, analogous to
the translated forms of other ELF data structures. Nothing uses these
formats as yet, but gdb may begin to. The format layouts are generic ELF.
Approved to commit?
Thanks,
Roland
bfd/ChangeLog:
2003-05-15 Roland McGrath <roland@redhat.com>
* elf.c (elfcore_grok_note): Grok NT_AUXV note, make ".auxv" section.
include/elf/ChangeLog:
2003-05-15 Roland McGrath <roland@redhat.com>
* common.h (NT_AUXV, AT_*): New macros.
* external.h (Elf32_External_Auxv, Elf64_External_Auxv): New types.
* internal.h (Elf_Internal_Auxv): New type.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.185
diff -B -b -p -u -r1.185 elf.c
--- bfd/elf.c 13 May 2003 15:32:19 -0000 1.185
+++ bfd/elf.c 19 May 2003 21:39:07 -0000
@@ -6884,6 +6884,20 @@ elfcore_grok_note (abfd, note)
#else
return TRUE;
#endif
+
+ case NT_AUXV:
+ {
+ asection *sect = bfd_make_section (abfd, ".auxv");
+
+ if (sect == NULL)
+ return FALSE;
+ sect->_raw_size = note->descsz;
+ sect->filepos = note->descpos;
+ sect->flags = SEC_HAS_CONTENTS;
+ sect->alignment_power = 1 + BFD_ARCH_SIZE / 32;
+
+ return TRUE;
+ }
}
}
Index: include/elf/ChangeLog
===================================================================
RCS file: /cvs/src/src/include/elf/ChangeLog,v
retrieving revision 1.171
diff -B -b -p -u -r1.171 ChangeLog
--- include/elf/ChangeLog 16 May 2003 23:40:08 -0000 1.171
+++ include/elf/ChangeLog 19 May 2003 21:39:09 -0000
@@ -1,3 +1,9 @@
+2003-05-15 Roland McGrath <roland@redhat.com>
+
+ * common.h (NT_AUXV, AT_*): New macros.
+ * external.h (Elf32_External_Auxv, Elf64_External_Auxv): New types.
+ * internal.h (Elf_Internal_Auxv): New type.
+
2003-05-14 Michael Snyder <msnyder@redhat.com>
From Bernd Schmidt <bernds@redhat.com>
* h8.h (E_H8_MACH_H8300SX): New.
Index: include/elf/common.h
===================================================================
RCS file: /cvs/src/src/include/elf/common.h,v
retrieving revision 1.57
diff -B -b -p -u -r1.57 common.h
--- include/elf/common.h 23 Apr 2003 21:09:04 -0000 1.57
+++ include/elf/common.h 19 May 2003 21:39:09 -0000
@@ -364,6 +364,7 @@
#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
#define NT_TASKSTRUCT 4 /* Contains copy of task struct */
+#define NT_AUXV 6 /* Contains copy of Elfxx_auxv_t */
#define NT_PRXFPREG 0x46e62b7f /* Contains a user_xfpregs_struct; */
/* note name must be "LINUX". */
@@ -686,5 +687,36 @@
/* Section Group Flags. */
#define GRP_COMDAT 0x1 /* A COMDAT group */
+
+/* Auxv a_type values. */
+
+#define AT_NULL 0 /* End of vector */
+#define AT_IGNORE 1 /* Entry should be ignored */
+#define AT_EXECFD 2 /* File descriptor of program */
+#define AT_PHDR 3 /* Program headers for program */
+#define AT_PHENT 4 /* Size of program header entry */
+#define AT_PHNUM 5 /* Number of program headers */
+#define AT_PAGESZ 6 /* System page size */
+#define AT_BASE 7 /* Base address of interpreter */
+#define AT_FLAGS 8 /* Flags */
+#define AT_ENTRY 9 /* Entry point of program */
+#define AT_NOTELF 10 /* Program is not ELF */
+#define AT_UID 11 /* Real uid */
+#define AT_EUID 12 /* Effective uid */
+#define AT_GID 13 /* Real gid */
+#define AT_EGID 14 /* Effective gid */
+#define AT_CLKTCK 17 /* Frequency of times() */
+#define AT_PLATFORM 15 /* String identifying platform. */
+#define AT_HWCAP 16 /* Machine dependent hints about
+ processor capabilities. */
+#define AT_FPUCW 18 /* Used FPU control word. */
+#define AT_DCACHEBSIZE 19 /* Data cache block size. */
+#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
+#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
+#define AT_IGNOREPPC 22 /* Entry should be ignored */
+/* Pointer to the global system page used for system calls and other
+ nice things. */
+#define AT_SYSINFO 32
+#define AT_SYSINFO_EHDR 33
#endif /* _ELF_COMMON_H */
Index: include/elf/external.h
===================================================================
RCS file: /cvs/src/src/include/elf/external.h,v
retrieving revision 1.4
diff -B -b -p -u -r1.4 external.h
--- include/elf/external.h 17 Dec 2001 00:52:34 -0000 1.4
+++ include/elf/external.h 19 May 2003 21:39:09 -0000
@@ -258,4 +258,19 @@ typedef struct
unsigned char si_flags[2];
} Elf_External_Syminfo;
+
+/* This structure appears on the stack and in NT_AUXV core file notes. */
+typedef struct
+{
+ unsigned char a_type[4];
+ unsigned char a_val[4];
+} Elf32_External_Auxv;
+
+typedef struct
+{
+ unsigned char a_type[8];
+ unsigned char a_val[8];
+} Elf64_External_Auxv;
+
+
#endif /* _ELF_EXTERNAL_H */
Index: include/elf/internal.h
===================================================================
RCS file: /cvs/src/src/include/elf/internal.h,v
retrieving revision 1.9
diff -B -b -p -u -r1.9 internal.h
--- include/elf/internal.h 28 Nov 2002 11:55:34 -0000 1.9
+++ include/elf/internal.h 19 May 2003 21:39:09 -0000
@@ -214,6 +214,13 @@ typedef struct
unsigned short int si_flags;
} Elf_Internal_Syminfo;
+/* This structure appears on the stack and in NT_AUXV core file notes. */
+typedef struct
+{
+ bfd_vma a_type;
+ bfd_vma a_val;
+} Elf_Internal_Auxv;
+
/* This structure is used to describe how sections should be assigned
to program segments. */