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
This commit is contained in:
parent
a5c69b1e49
commit
2bb8c72b39
5 changed files with 48 additions and 21 deletions
|
@ -26,7 +26,7 @@ standard_testfile
|
||||||
# the "-Wl,-Ttext-segment" option compile the binary.
|
# the "-Wl,-Ttext-segment" option compile the binary.
|
||||||
|
|
||||||
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
|
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
|
||||||
[list debug ldflags=-Wl,-Ttext-segment=0xb0000000]] } {
|
[list debug text_segment=0xb0000000]] } {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,20 +32,8 @@ if { [gdb_compile [file join $srcdir $subdir $srcfile] $objfile \
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
set opts1_ld [list debug ldflags=-Wl,-Ttext-segment=0x1000000]
|
if { [gdb_compile $objfile $exec1 executable {debug text_segment=0x1000000}] != ""
|
||||||
set opts1_gold [list debug ldflags=-Wl,-Ttext=0x1000000]
|
|| [gdb_compile $objfile $exec2 executable {debug text_segment=0x2000000}] != ""} {
|
||||||
set opts2_ld [list debug ldflags=-Wl,-Ttext-segment=0x2000000]
|
|
||||||
set opts2_gold [list debug ldflags=-Wl,-Ttext=0x2000000]
|
|
||||||
|
|
||||||
if { [gdb_compile $objfile $exec1 executable $opts1_ld] != "" } {
|
|
||||||
# Old gold linker versions don't support -Ttext-segment. Fall
|
|
||||||
# back to -Ttext.
|
|
||||||
if { [gdb_compile $objfile $exec1 executable $opts1_gold] != ""
|
|
||||||
|| [gdb_compile $objfile $exec2 executable $opts2_gold] != ""} {
|
|
||||||
untested "link failed"
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
} elseif { [gdb_compile $objfile $exec2 executable $opts2_ld] != "" } {
|
|
||||||
untested "link failed"
|
untested "link failed"
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ proc do_test { execr_thread different_text_segments displaced_stepping } {
|
||||||
set execd_opts [list debug]
|
set execd_opts [list debug]
|
||||||
|
|
||||||
if { $different_text_segments } {
|
if { $different_text_segments } {
|
||||||
lappend execr_opts "ldflags=-Wl,-Ttext-segment=0x600000"
|
lappend execr_opts "text_segment=0x600000"
|
||||||
lappend execd_opts "ldflags=-Wl,-Ttext-segment=0x800000"
|
lappend execd_opts "text_segment=0x800000"
|
||||||
}
|
}
|
||||||
|
|
||||||
if { $execr_thread == "leader" } {
|
if { $execr_thread == "leader" } {
|
||||||
|
|
|
@ -4351,6 +4351,7 @@ set gdb_saved_set_unbuffered_mode_obj ""
|
||||||
# - nopie: Prevent creation of PIE executables.
|
# - nopie: Prevent creation of PIE executables.
|
||||||
# - macros: Add the required compiler flag to include macro information in
|
# - macros: Add the required compiler flag to include macro information in
|
||||||
# debug information
|
# debug information
|
||||||
|
# - text_segment=addr: Tell the linker to place the text segment at ADDR.
|
||||||
#
|
#
|
||||||
# And here are some of the not too obscure options understood by DejaGnu that
|
# And here are some of the not too obscure options understood by DejaGnu that
|
||||||
# influence the compilation:
|
# influence the compilation:
|
||||||
|
@ -4470,6 +4471,19 @@ proc gdb_compile {source dest type options} {
|
||||||
} elseif { $opt == "getting_compiler_info" } {
|
} elseif { $opt == "getting_compiler_info" } {
|
||||||
# If this is set, calling test_compiler_info will cause recursion.
|
# If this is set, calling test_compiler_info will cause recursion.
|
||||||
set getting_compiler_info 1
|
set getting_compiler_info 1
|
||||||
|
} elseif {[regexp "^text_segment=(.*)" $opt dummy_var addr]} {
|
||||||
|
if { [linker_supports_Ttext_segment_flag] } {
|
||||||
|
# For GNU ld.
|
||||||
|
lappend new_options "ldflags=-Wl,-Ttext-segment=$addr"
|
||||||
|
} elseif { [linker_supports_image_base_flag] } {
|
||||||
|
# For LLVM's lld.
|
||||||
|
lappend new_options "ldflags=-Wl,--image-base=$addr"
|
||||||
|
} elseif { [linker_supports_Ttext_flag] } {
|
||||||
|
# For old GNU gold versions.
|
||||||
|
lappend new_options "ldflags=-Wl,-Ttext=$addr"
|
||||||
|
} else {
|
||||||
|
error "Don't know how to handle text_segment option."
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
lappend new_options $opt
|
lappend new_options $opt
|
||||||
}
|
}
|
||||||
|
@ -8235,6 +8249,31 @@ gdb_caching_proc have_fuse_ld_gold {
|
||||||
return [gdb_simple_compile $me $src executable $flags]
|
return [gdb_simple_compile $me $src executable $flags]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Return 1 if linker supports -Ttext-segment, otherwise return 0.
|
||||||
|
gdb_caching_proc linker_supports_Ttext_segment_flag {
|
||||||
|
set me "linker_supports_Ttext_segment_flag"
|
||||||
|
set flags additional_flags="-Wl,-Ttext-segment=0x7000000"
|
||||||
|
set src { int main() { return 0; } }
|
||||||
|
return [gdb_simple_compile $me $src executable $flags]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return 1 if linker supports -Ttext, otherwise return 0.
|
||||||
|
gdb_caching_proc linker_supports_Ttext_flag {
|
||||||
|
set me "linker_supports_Ttext_flag"
|
||||||
|
set flags additional_flags="-Wl,-Ttext=0x7000000"
|
||||||
|
set src { int main() { return 0; } }
|
||||||
|
return [gdb_simple_compile $me $src executable $flags]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return 1 if linker supports --image-base, otherwise 0.
|
||||||
|
gdb_caching_proc linker_supports_image_base_flag {
|
||||||
|
set me "linker_supports_image_base_flag"
|
||||||
|
set flags additional_flags="-Wl,--image-base=0x7000000"
|
||||||
|
set src { int main() { return 0; } }
|
||||||
|
return [gdb_simple_compile $me $src executable $flags]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Return 1 if compiler supports scalar_storage_order attribute, otherwise
|
# Return 1 if compiler supports scalar_storage_order attribute, otherwise
|
||||||
# return 0.
|
# return 0.
|
||||||
gdb_caching_proc supports_scalar_storage_order_attribute {
|
gdb_caching_proc supports_scalar_storage_order_attribute {
|
||||||
|
|
|
@ -88,14 +88,14 @@ proc compile_and_download_n_jit_so {jit_solib_basename jit_solib_srcfile count}
|
||||||
# wouldn't work for .debug sections. Also, output for "info
|
# wouldn't work for .debug sections. Also, output for "info
|
||||||
# function" changes when debug info is present.
|
# function" changes when debug info is present.
|
||||||
set addr [format 0x%x [expr $jit_load_address + $jit_load_increment * [expr $i-1]]]
|
set addr [format 0x%x [expr $jit_load_address + $jit_load_increment * [expr $i-1]]]
|
||||||
# Using -Ttext-segment flag to ask linked to relocate everything
|
|
||||||
# in the compiled shared library against a fixed base address. Combined
|
# Use "text_segment=..." to ask the linker to relocate everything in the
|
||||||
|
# compiled shared library against a fixed base address. Combined
|
||||||
# with mapping the resulting binary to the same fixed base it allows
|
# with mapping the resulting binary to the same fixed base it allows
|
||||||
# to dynamically execute functions from it without any further adjustments.
|
# to dynamically execute functions from it without any further adjustments.
|
||||||
set options [list \
|
set options [list \
|
||||||
additional_flags=-DFUNCTION_NAME=[format "jit_function_%04d" $i] \
|
additional_flags=-DFUNCTION_NAME=[format "jit_function_%04d" $i] \
|
||||||
additional_flags=-Xlinker \
|
text_segment=$addr]
|
||||||
additional_flags=-Ttext-segment=$addr]
|
|
||||||
if { [gdb_compile_shlib ${jit_solib_srcfile} ${binfile} \
|
if { [gdb_compile_shlib ${jit_solib_srcfile} ${binfile} \
|
||||||
$options] != "" } {
|
$options] != "" } {
|
||||||
set f [file tail $binfile]
|
set f [file tail $binfile]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue