summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-01-19 13:17:47 -0800
committerH.J. Lu <hjl.tools@gmail.com>2016-01-19 13:41:38 -0800
commitaac33577555ae1e44915fabc90e2b9ce66b32941 (patch)
tree18cbcd5551ddfe890c6a69d3796986def660da95
parent40068dccc4f9c86cb9e7c425c4ab3e272312affb (diff)
downloadbinutils-gdb-users/hjl/gcore.tar.gz
Pass enum elf_os to elfcore_write_prstatususers/hjl/gcore
-rw-r--r--bfd/elf-bfd.h15
-rw-r--r--bfd/elf.c7
-rw-r--r--bfd/elf32-arm.c5
-rw-r--r--bfd/elf32-ppc.c6
-rw-r--r--bfd/elf64-ppc.c7
-rw-r--r--bfd/elf64-x86-64.c5
-rw-r--r--bfd/elfxx-aarch64.c7
-rw-r--r--bfd/elfxx-aarch64.h3
-rw-r--r--gdb/fbsd-tdep.c6
-rw-r--r--gdb/linux-tdep.c2
10 files changed, 46 insertions, 17 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 6a04f044e78..6bf9772fea8 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -749,6 +749,15 @@ enum action_discarded
PRETEND = 2
};
+enum elf_os
+ {
+ os_unknown = 0,
+ os_linux,
+ os_freebsd,
+ os_netbsd,
+ os_openbsd
+ };
+
typedef asection * (*elf_gc_mark_hook_fn)
(asection *, struct bfd_link_info *, Elf_Internal_Rela *,
struct elf_link_hash_entry *, Elf_Internal_Sym *);
@@ -1192,7 +1201,7 @@ struct elf_backend_data
/* This function, if defined, is called to write a note to a corefile. */
char *(*elf_backend_write_core_note)
- (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
+ (bfd *abfd, char *buf, int *bufsiz, enum elf_os, int note_type, ...);
/* This function, if defined, is called to convert target-specific
section flag names into hex values. */
@@ -2351,9 +2360,9 @@ extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
extern char *elfcore_write_note
(bfd *, char *, int *, const char *, int, const void *, int);
extern char *elfcore_write_prpsinfo
- (bfd *, char *, int *, const char *, const char *);
+ (bfd *, enum elf_os, char *, int *, const char *, const char *);
extern char *elfcore_write_prstatus
- (bfd *, char *, int *, long, int, const void *);
+ (bfd *, enum elf_os, char *, int *, long, int, const void *);
extern char * elfcore_write_pstatus
(bfd *, char *, int *, long, int, const void *);
extern char *elfcore_write_prfpreg
diff --git a/bfd/elf.c b/bfd/elf.c
index b2a50bff3e7..2be52a7e4e1 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9727,6 +9727,7 @@ elfcore_write_note (bfd *abfd,
char *
elfcore_write_prpsinfo (bfd *abfd,
+ enum elf_os os,
char *buf,
int *bufsiz,
const char *fname,
@@ -9738,7 +9739,8 @@ elfcore_write_prpsinfo (bfd *abfd,
{
char *ret;
ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz,
- NT_PRPSINFO, fname, psargs);
+ os, NT_PRPSINFO,
+ fname, psargs);
if (ret != NULL)
return ret;
}
@@ -9814,6 +9816,7 @@ elfcore_write_linux_prpsinfo64
char *
elfcore_write_prstatus (bfd *abfd,
+ enum elf_os os,
char *buf,
int *bufsiz,
long pid,
@@ -9826,7 +9829,7 @@ elfcore_write_prstatus (bfd *abfd,
{
char *ret;
ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz,
- NT_PRSTATUS,
+ os, NT_PRSTATUS,
pid, cursig, gregs);
if (ret != NULL)
return ret;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 1c52526b611..9a78ec923d3 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2052,8 +2052,11 @@ elf32_arm_nabi_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
static char *
elf32_arm_nabi_write_core_note (bfd *abfd, char *buf, int *bufsiz,
- int note_type, ...)
+ enum elf_os os, int note_type, ...)
{
+ if (os != os_linux)
+ abort ();
+
switch (note_type)
{
default:
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 54cb5d4edc7..9046eae770d 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -2310,8 +2310,12 @@ elfcore_write_ppc_linux_prpsinfo32 (bfd *abfd, char *buf, int *bufsiz,
}
static char *
-ppc_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, ...)
+ppc_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz,
+ enum elf_os os, int note_type, ...)
{
+ if (os != os_linux)
+ abort ();
+
switch (note_type)
{
default:
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index f9c37b5b3de..2e37901eac2 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -2948,9 +2948,12 @@ ppc64_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
}
static char *
-ppc64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
- ...)
+ppc64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz,
+ enum elf_os os, int note_type, ...)
{
+ if (os != os_linux)
+ abort ();
+
switch (note_type)
{
default:
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index bbdb03a58cf..f2997447c9d 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -440,7 +440,7 @@ elf_x86_64_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
#ifdef CORE_HEADER
static char *
elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
- int note_type, ...)
+ enum elf_os os, int note_type, ...)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
va_list ap;
@@ -449,6 +449,9 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
int cursig;
const void *gregs;
+ if (os != os_linux)
+ abort ();
+
switch (note_type)
{
default:
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index 498171cba89..d9cee2098ad 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -613,9 +613,12 @@ _bfd_aarch64_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
}
char *
-_bfd_aarch64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
- ...)
+_bfd_aarch64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz,
+ enum elf_os os, int note_type, ...)
{
+ if (os != os_linux)
+ abort ();
+
switch (note_type)
{
default:
diff --git a/bfd/elfxx-aarch64.h b/bfd/elfxx-aarch64.h
index 2a3dd81ae51..d4c22c45647 100644
--- a/bfd/elfxx-aarch64.h
+++ b/bfd/elfxx-aarch64.h
@@ -59,7 +59,8 @@ extern bfd_boolean
_bfd_aarch64_elf_grok_psinfo (bfd *, Elf_Internal_Note *);
extern char *
-_bfd_aarch64_elf_write_core_note (bfd *, char *, int *, int, ...);
+_bfd_aarch64_elf_write_core_note (bfd *, char *, int *, enum elf_os,
+ int, ...);
#define elf_backend_add_symbol_hook _bfd_aarch64_elf_add_symbol_hook
#define elf_backend_grok_prstatus _bfd_aarch64_elf_grok_prstatus
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 7310ea09208..0481dd8ee14 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -137,7 +137,7 @@ fbsd_collect_regset_section_cb (const char *sect_name, int size,
/* PRSTATUS still needs to be treated specially. */
if (strcmp (sect_name, ".reg") == 0)
data->note_data = (char *) elfcore_write_prstatus
- (data->obfd, data->note_data, data->note_size, data->lwp,
+ (data->obfd, os_freebsd, data->note_data, data->note_size, data->lwp,
gdb_signal_to_host (data->stop_signal), buf);
else
data->note_data = (char *) elfcore_write_register_note
@@ -232,8 +232,8 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
psargs = reconcat (psargs, psargs, " ", get_inferior_args (),
(char *) NULL);
- note_data = elfcore_write_prpsinfo (obfd, note_data, note_size,
- fname, psargs);
+ note_data = elfcore_write_prpsinfo (obfd, os_freebsd, note_data,
+ note_size, fname, psargs);
}
/* Thread register information. */
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 29f5f3c003e..291e8917c4c 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1565,7 +1565,7 @@ linux_collect_regset_section_cb (const char *sect_name, int size,
/* PRSTATUS still needs to be treated specially. */
if (strcmp (sect_name, ".reg") == 0)
data->note_data = (char *) elfcore_write_prstatus
- (data->obfd, data->note_data, data->note_size, data->lwp,
+ (data->obfd, os_linux, data->note_data, data->note_size, data->lwp,
gdb_signal_to_host (data->stop_signal), buf);
else
data->note_data = (char *) elfcore_write_register_note