return -1
}
-set opts1_ld [list debug ldflags=-Wl,-Ttext-segment=0x1000000]
-set opts1_gold [list debug ldflags=-Wl,-Ttext=0x1000000]
-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] != "" } {
+if { [gdb_compile $objfile $exec1 executable {debug text_segment=0x1000000}] != ""
+ || [gdb_compile $objfile $exec2 executable {debug text_segment=0x2000000}] != ""} {
untested "link failed"
return -1
}
# - nopie: Prevent creation of PIE executables.
# - macros: Add the required compiler flag to include macro information in
# 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
# influence the compilation:
} elseif { $opt == "getting_compiler_info" } {
# If this is set, calling test_compiler_info will cause recursion.
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 {
lappend new_options $opt
}
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 0.
gdb_caching_proc supports_scalar_storage_order_attribute {
# wouldn't work for .debug sections. Also, output for "info
# function" changes when debug info is present.
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
# to dynamically execute functions from it without any further adjustments.
set options [list \
additional_flags=-DFUNCTION_NAME=[format "jit_function_%04d" $i] \
- additional_flags=-Xlinker \
- additional_flags=-Ttext-segment=$addr]
+ text_segment=$addr]
if { [gdb_compile_shlib ${jit_solib_srcfile} ${binfile} \
$options] != "" } {
set f [file tail $binfile]