diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-11-11 15:35:05 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-11-18 11:21:37 +0000 |
commit | ed64647b7f32b067e910ae7b24b477e11b268d5d (patch) | |
tree | 61094802395e4e8762595b1b35add42eea2a62ab /gas/config/tc-xgate.h | |
parent | 33c1395cf5e9deec7733691ba32c450e5c27f757 (diff) | |
download | gdb-ed64647b7f32b067e910ae7b24b477e11b268d5d.zip gdb-ed64647b7f32b067e910ae7b24b477e11b268d5d.tar.gz gdb-ed64647b7f32b067e910ae7b24b477e11b268d5d.tar.bz2 |
gdb/testsuite: fix gdb.compile/compile-ops.exp with clang
I noticed that the gdb.compile/compile-ops.exp test was failing when
run with Clang as the compiler.
This test makes use of the DWARF assembler, and, it turns out, uses
a technique which is not portable to Clang. This problem is
described in the comment on the function_range proc in lib/dwarf.exp,
the explanation is:
# If the compiler is gcc, we can do the following to get function start
# and end address too:
#
# asm ("func_start: .globl func_start");
# static void func (void) {}
# asm ("func_end: .globl func_end");
#
# however, this isn't portable, because other compilers, such as clang,
# may not guarantee the order of global asms and function. The code
# becomes:
#
# asm ("func_start: .globl func_start");
# asm ("func_end: .globl func_end");
# static void func (void) {}
These start/end labels are used for computing the function start, end,
and length. The portable solution is to place a label within the
function, like this:
# int main (void)
# {
# asm ("main_label: .globl main_label");
# return 0;
# }
And make use of 'proc function_range' (from lib/dwarf.exp).
So, that's what I do in this commit.
One consequence of this change is that we need to compile the source
file, and have it loaded into a GDB session, before calling
function_range, so I've added an early call to prepare_for_testing.
Additionally, this test script was generating the DWARF assembler into
a file called gdbjit-ops.S, I suspect a copy and paste issue there, so
I've switched this to use compile-ops-dbg.S instead, which is more
inline with what other DWARF assembler tests do.
The only other change, which might be a problem, is that I also
deleted these two lines from the source file:
asm (".section \".text\"");
asm (".balign 8");
These lines were setting the alignment of the .text section. What I
don't know is whether this was significant or not. If it is
significant, then I can't see why.
On x86-64, the test still passes fine without these lines, but that
doesn't mean the test wont start failing on some other architecture.
Still, I figure, lets remove them, then, if/when we find a test that
starts failing, we can add the lines back, along with an explanation
for why the extra alignment is required.
But, if people would prefer to be more conservative, then I'm happy to
just add the lines back.
Reviewed-By: Lancelot SIX <lancelot.six@amd.com>
Diffstat (limited to 'gas/config/tc-xgate.h')
0 files changed, 0 insertions, 0 deletions