Skip to content

Commit

Permalink
Implemented the capability of building crash as an x86_64 binary
Browse files Browse the repository at this point in the history
for analyzing little-endian PPC64 dumpfiles on an x86_64 host, which
can be done by entering "make target=PPC64".  After the initial build
is complete, subsequent builds can be done by entering "make" alone.
([email protected])
  • Loading branch information
Dave Anderson committed Nov 20, 2014
1 parent ffe1550 commit d5d022d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ gdb_patch:
if [ "${ARCH}" = "ppc64le" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \
patch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \
fi
if [ "${ARCH}" = "x86_64" ] && [ "${TARGET}" = "PPC64" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \
patch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \
fi

library: make_build_data ${OBJECT_FILES}
ar -rs ${PROGRAM}lib.a ${OBJECT_FILES}
Expand Down
31 changes: 29 additions & 2 deletions configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,16 @@ void add_extra_lib(char *);
#define TARGET_CFLAGS_PPC_ON_PPC64 "TARGET_CFLAGS=-m32 -D_FILE_OFFSET_BITS=64 -fPIC"
#define TARGET_CFLAGS_ARM64 "TARGET_CFLAGS="
#define TARGET_CFLAGS_ARM64_ON_X86_64 "TARGET_CFLAGS="
#define TARGET_CFLAGS_PPC64_ON_X86_64 "TARGET_CFLAGS="

#define GDB_TARGET_DEFAULT "GDB_CONF_FLAGS="
#define GDB_TARGET_ARM_ON_X86 "GDB_CONF_FLAGS=--target=arm-elf-linux"
#define GDB_TARGET_ARM_ON_X86_64 "GDB_CONF_FLAGS=--target=arm-elf-linux CFLAGS=-m32"
#define GDB_TARGET_X86_ON_X86_64 "GDB_CONF_FLAGS=--target=i686-pc-linux-gnu CFLAGS=-m32"
#define GDB_TARGET_PPC_ON_PPC64 "GDB_CONF_FLAGS=--target=ppc-elf-linux CFLAGS=-m32"
#define GDB_TARGET_ARM64_ON_X86_64 "GDB_CONF_FLAGS=--target=aarch64-elf-linux" /* TBD */

#define GDB_TARGET_PPC64_ON_X86_64 "GDB_CONF_FLAGS=--target=powerpc64le-unknown-linux-gnu"

/*
* The original plan was to allow the use of a particular version
* of gdb for a given architecture. But for practical purposes,
Expand Down Expand Up @@ -394,6 +396,12 @@ get_current_configuration(struct supported_gdb_version *sp)
* Build an ARM64 crash binary on an X86_64 host.
*/
target_data.target = ARM64;
} else if ((target_data.target == X86_64) &&
(name_to_target((char *)target_data.target_as_param) == PPC64)) {
/*
* Build a PPC64 little-endian crash binary on an X86_64 host.
*/
target_data.target = PPC64;
} else if ((target_data.target == PPC64) &&
(name_to_target((char *)target_data.target_as_param) == PPC)) {
/*
Expand Down Expand Up @@ -454,6 +462,17 @@ get_current_configuration(struct supported_gdb_version *sp)
(target_data.initial_gdb_target != ARM64))
arch_mismatch(sp);

if ((target_data.initial_gdb_target == PPC64) &&
(target_data.target != PPC64)) {
if (target_data.target == X86_64)
target_data.target = PPC64;
else
arch_mismatch(sp);
}
if ((target_data.target == PPC64) &&
(target_data.initial_gdb_target != PPC64))
arch_mismatch(sp);

if ((target_data.initial_gdb_target == PPC) &&
(target_data.target != PPC)) {
if (target_data.target == PPC64)
Expand Down Expand Up @@ -640,7 +659,11 @@ build_configure(struct supported_gdb_version *sp)
break;
case PPC64:
target = TARGET_PPC64;
target_CFLAGS = TARGET_CFLAGS_PPC64;
if (target_data.host == X86_64) {
target_CFLAGS = TARGET_CFLAGS_PPC64_ON_X86_64;
gdb_conf_flags = GDB_TARGET_PPC64_ON_X86_64;
} else
target_CFLAGS = TARGET_CFLAGS_PPC64;
break;
case X86_64:
target = TARGET_X86_64;
Expand Down Expand Up @@ -1529,6 +1552,10 @@ name_to_target(char *name)
return PPC64;
else if (strncmp(name, "ppc64", strlen("ppc64")) == 0)
return PPC64;
else if (strncmp(name, "ppc64le", strlen("ppc64le")) == 0)
return PPC64;
else if (strncmp(name, "PPC64LE", strlen("PPC64LE")) == 0)
return PPC64;
else if (strncmp(name, "PPC", strlen("PPC")) == 0)
return PPC;
else if (strncmp(name, "ppc", strlen("ppc")) == 0)
Expand Down
4 changes: 4 additions & 0 deletions ppc64.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ struct machine_specific book3e_machine_specific = {
void
ppc64_init(int when)
{
#if defined(__x86_64__)
if (ACTIVE())
error(FATAL, "compiled for the PPC64 architecture\n");
#endif
switch (when)
{
case PRE_SYMTAB:
Expand Down

0 comments on commit d5d022d

Please sign in to comment.