aboutsummaryrefslogtreecommitdiff
path: root/gdb/osabi.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2018-04-07 13:24:58 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2018-04-07 13:34:59 -0400
commitc912f608be7bc2598b919da2b11721b3c262d154 (patch)
treec9686de8c39ced960efbcd3e082fd2f5c2df9575 /gdb/osabi.c
parent26540402495f35d5f19762ceba66605bca8fa63b (diff)
downloadbinutils-c912f608be7bc2598b919da2b11721b3c262d154.zip
binutils-c912f608be7bc2598b919da2b11721b3c262d154.tar.gz
binutils-c912f608be7bc2598b919da2b11721b3c262d154.tar.bz2
Fix generation of x86-64 gdbarch with osabi none (PR 22979)
When a 64-bits (x86-64) gdbarch is created, it is first born as a 32-bits gdbarch in i386_gdbarch_init. The call gdbarch_init_osabi will call the handler register for the selected (arch, osabi) pair, such as amd64_linux_init_abi. The various amd64 handlers call amd64_init_abi, which turns the gdbarch into a 64-bits one. When selecting the i386:x86-64 architecture with no osabi, no such handler is ever called, so the gdbarch stays (wrongfully) a 32-bits one. My first idea was to manually call amd64_init_abi & al in i386_gdbarch_init when the osabi is GDB_OSABI_NONE. However, this doesn't work in a build of GDB where i386 is included as a target but not amd64. My next option (implemented in this patch), is to allow registering handlers for GDB_OSABI_NONE. I added two such handlers in amd64-tdep.c, so now it works the same as for the "normal" osabis. It required re-ordering things in gdbarch_init_osabi to allow running handlers for GDB_OSABI_NONE. Without this patch applied (but with the previous one*) : (gdb) set osabi none (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) p sizeof(void*) $1 = 4 and now: (gdb) set osabi none (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) p sizeof(void*) $1 = 8 * Before the previous patch, which fixed "set osabi none", this bug was hidden because we didn't actually try to generate a gdbarch for no osabi, it would always fall back on Linux. Generating the gdbarch for amd64/linux did work. gdb/ChangeLog: PR gdb/22979 * amd64-tdep.c (amd64_none_init_abi): New function. (amd64_x32_none_init_abi): New function. (_initialize_amd64_tdep): Register handlers for x86-64 and x64_32 with GDB_OSABI_NONE. * osabi.c (gdbarch_init_osabi): Allow running handlers for the GDB_OSABI_NONE osabi. gdb/testsuite/ChangeLog: PR gdb/22979 * gdb.arch/amd64-osabi.exp: New file.
Diffstat (limited to 'gdb/osabi.c')
-rw-r--r--gdb/osabi.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gdb/osabi.c b/gdb/osabi.c
index ef1d993..7d0540b 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -338,13 +338,6 @@ gdbarch_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
gdb_assert (info.osabi != GDB_OSABI_UNKNOWN);
- if (info.osabi == GDB_OSABI_NONE)
- {
- /* Don't complain about no OSABI. Assume the user knows
- what they are doing. */
- return;
- }
-
for (handler = gdb_osabi_handler_list; handler != NULL;
handler = handler->next)
{
@@ -378,6 +371,13 @@ gdbarch_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
}
}
+ if (info.osabi == GDB_OSABI_NONE)
+ {
+ /* Don't complain about no OSABI. Assume the user knows
+ what they are doing. */
+ return;
+ }
+
warning
("A handler for the OS ABI \"%s\" is not built into this configuration\n"
"of GDB. Attempting to continue with the default %s settings.\n",