gdb/testsuite: add text_segment option to gdb_compile
authorVignesh Balasubramanian <Vignesh.Balasubrmanian@amd.com>
Wed, 30 Mar 2022 10:59:43 +0000 (16:29 +0530)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 18 Apr 2022 14:24:48 +0000 (10:24 -0400)
commit2bb8c72b39f4dcce0be292b2c701edbe4dd4ca7c
tree1aa2073da43ac99f61a77e005c996ec5c1bb62de
parenta5c69b1e49bae4d0dcb20f324cebb310c63495c6
gdb/testsuite: add text_segment option to gdb_compile

LLVM's lld linker doesn't have the "-Ttext-segment" option, but
"--image-base" can be used instead.

To centralize the logic of checking which option is supported, add the
text_segment option to gdb_compile.  Change tests that are currently
using -Ttext-segment to use that new option instead.

This patch fixes only compilation error, for example:

Before:

    $ make check TESTS="gdb.base/jit-elf.exp" RUNTESTFLAGS="CC_FOR_TARGET=clang LDFLAGS_FOR_TARGET=-fuse-ld=ld"
    Running /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jit-elf.exp ...
    gdb compile failed, clang-13: warning: -Xlinker -Ttext-segment=0x7000000: 'linker' input unused [-Wunused-command-line-argument]

After:

    $ make check TESTS="gdb.base/jit-elf.exp" RUNTESTFLAGS="CC_FOR_TARGET=clang LDFLAGS_FOR_TARGET=-fuse-ld=ld"
    Running /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jit-elf.exp ...
    FAIL: gdb.base/jit-elf.exp: one_jit_test-1: continue to breakpoint: break here 1
    FAIL: gdb.base/jit-elf.exp: one_jit_test-1: continue to breakpoint: break here 2
    FAIL: gdb.base/jit-elf.exp: one_jit_test-2: continue to breakpoint: break here 1
    FAIL: gdb.base/jit-elf.exp: one_jit_test-2: info function ^jit_function
    FAIL: gdb.base/jit-elf.exp: one_jit_test-2: continue to breakpoint: break here 2
    FAIL: gdb.base/jit-elf.exp: attach: one_jit_test-2: continue to breakpoint: break here 1
    FAIL: gdb.base/jit-elf.exp: attach: one_jit_test-2: break here 1: attach
    FAIL: gdb.base/jit-elf.exp: PIE: one_jit_test-1: continue to breakpoint: break here 1
    FAIL: gdb.base/jit-elf.exp: PIE: one_jit_test-1: continue to breakpoint: break here 2

                    === gdb Summary ===

    # of expected passes            26
    # of unexpected failures        9

Change-Id: I3678c5c9bbfc2f80671698e28a038e6b3d14e635
gdb/testsuite/gdb.arch/arm-bl-branch-dest.exp
gdb/testsuite/gdb.base/execl-update-breakpoints.exp
gdb/testsuite/gdb.threads/step-over-exec.exp
gdb/testsuite/lib/gdb.exp
gdb/testsuite/lib/jit-elf-helpers.exp