gdb/testsuite: re-compile entry-value-typedef .S files with -fPIE

As Luis pointed out here [1], the AArch64 variant of the test doesn't
work on systems that use PIE by default.  For example, on this Debian
11:

    $ make check TESTS="gdb.dwarf2/entry-value-typedef.exp"
    gdb compile failed, /usr/bin/ld: /tmp/ccJE8ZSr.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZNSsD1Ev@@GLIBCXX_3.4' which may bind externally can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccJE8ZSr.o(.text+0x38): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `_ZNSsD1Ev@@GLIBCXX_3.4'

This is because entry-value-typedef-aarch64.S was generated on an old
system that does not generate position-independent code by default, but
the system the test runs on tries to link the test executable as
position-independent.  Fix this by regenerating the same binary on the
same system as the original one, but with -fPIE this time.  Do the same
for the amd64 binary, although this one was already position-independent
so the generated code doesn't change.

With this patch applied, the test passes on the Debian 11 AArch64
system.

[1] https://sourceware.org/pipermail/gdb-patches/2022-August/191462.html

Change-Id: I68d55adaa56a7a3eddb0c13980b1a98b791f8144
This commit is contained in:
Simon Marchi
2022-08-19 10:12:36 -04:00
parent 4afe8a8170
commit d7c8330389
2 changed files with 64 additions and 54 deletions

View File

@ -47,7 +47,8 @@ _ZL4funcRKi:
.cfi_offset 20, -360 .cfi_offset 20, -360
.LBB293: .LBB293:
.loc 1 28 0 .loc 1 28 0
add x0, x29, 32 add x20, x29, 32
mov x0, x20
.LVL1: .LVL1:
mov w1, 16 mov w1, 16
.LEHB0: .LEHB0:
@ -65,7 +66,7 @@ _ZL4funcRKi:
.file 2 "/usr/include/c++/4.8/sstream" .file 2 "/usr/include/c++/4.8/sstream"
.loc 2 472 0 .loc 2 472 0
mov x8, x0 mov x8, x0
add x0, x29, 40 add x0, x20, 8
.LEHB1: .LEHB1:
bl _ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv bl _ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv
.LEHE1: .LEHE1:
@ -74,33 +75,37 @@ _ZL4funcRKi:
.LBE294: .LBE294:
.loc 1 29 0 discriminator 1 .loc 1 29 0 discriminator 1
mov x0, x19 mov x0, x19
ldr x1, .LC0 adrp x1, :got:_ZTISs
adrp x2, _ZNSsD1Ev ldr x1, [x1, #:got_lo12:_ZTISs]
add x2, x2, :lo12:_ZNSsD1Ev adrp x2, :got:_ZNSsD1Ev
ldr x2, [x2, #:got_lo12:_ZNSsD1Ev]
.LEHB2: .LEHB2:
bl __cxa_throw bl __cxa_throw
.LEHE2: .LEHE2:
.LVL6: .LVL6:
.L4: .L4:
mov x20, x0 mov x20, x0
.LVL7:
.loc 1 29 0 is_stmt 0 .loc 1 29 0 is_stmt 0
mov x0, x19 mov x0, x19
bl __cxa_free_exception bl __cxa_free_exception
.LVL7: .LVL8:
mov x19, x20 mov x19, x20
b .L3 b .L3
.LVL9:
.L5: .L5:
mov x19, x0 mov x19, x0
.LVL10:
.L3: .L3:
add x0, x29, 32 add x0, x29, 32
.LVL8: .LVL11:
bl _ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev bl _ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev
.LVL9: .LVL12:
mov x0, x19 mov x0, x19
.LEHB3: .LEHB3:
bl _Unwind_Resume bl _Unwind_Resume
.LEHE3: .LEHE3:
.LVL10: .LVL13:
.LBE293: .LBE293:
.cfi_endproc .cfi_endproc
.LFE1299: .LFE1299:
@ -131,9 +136,6 @@ _ZL4funcRKi:
.LLSDACSE1299: .LLSDACSE1299:
.text .text
.size _ZL4funcRKi, .-_ZL4funcRKi .size _ZL4funcRKi, .-_ZL4funcRKi
.align 3
.LC0:
.xword _ZTISs
.align 2 .align 2
.global main .global main
.type main, %function .type main, %function
@ -152,12 +154,12 @@ main:
mov w1, 1234 mov w1, 1234
str w1, [x0,-4]! str w1, [x0,-4]!
bl _ZL4funcRKi bl _ZL4funcRKi
.LVL11: .LVL14:
.cfi_endproc .cfi_endproc
.LFE1300: .LFE1300:
.size main, .-main .size main, .-main
.weak _ZTISs .weak _ZTISs
.section .rodata._ZTISs,"aG",%progbits,_ZTISs,comdat .section .data.rel.ro._ZTISs,"awG",%progbits,_ZTISs,comdat
.align 3 .align 3
.type _ZTISs, %object .type _ZTISs, %object
.size _ZTISs, 16 .size _ZTISs, 16
@ -224,7 +226,7 @@ _ZTSSs:
.file 51 "/usr/include/aarch64-linux-gnu/c++/4.8/bits/gthr-default.h" .file 51 "/usr/include/aarch64-linux-gnu/c++/4.8/bits/gthr-default.h"
.section .debug_info,"",%progbits .section .debug_info,"",%progbits
.Ldebug_info0: .Ldebug_info0:
.4byte 0x51c9 .4byte 0x51bc
.2byte 0x4 .2byte 0x4
.4byte .Ldebug_abbrev0 .4byte .Ldebug_abbrev0
.byte 0x8 .byte 0x8
@ -5042,7 +5044,7 @@ _ZTSSs:
.4byte 0x2be0 .4byte 0x2be0
.4byte 0x2be6 .4byte 0x2be6
.uleb128 0x18 .uleb128 0x18
.4byte 0x5178 .4byte 0x516b
.byte 0 .byte 0
.uleb128 0x2b .uleb128 0x2b
.4byte .LASF458 .4byte .LASF458
@ -8958,17 +8960,17 @@ _ZTSSs:
.8byte .LFE1299-.LFB1299 .8byte .LFE1299-.LFB1299
.uleb128 0x1 .uleb128 0x1
.byte 0x9c .byte 0x9c
.4byte 0x507d .4byte 0x5070
.uleb128 0x73 .uleb128 0x73
.string "t" .string "t"
.byte 0x1 .byte 0x1
.byte 0x1a .byte 0x1a
.4byte 0x507d .4byte 0x5070
.4byte .LLST0 .4byte .LLST0
.uleb128 0x74 .uleb128 0x74
.8byte .LBB293 .8byte .LBB293
.8byte .LBE293-.LBB293 .8byte .LBE293-.LBB293
.4byte 0x5068 .4byte 0x505b
.uleb128 0x75 .uleb128 0x75
.string "oss" .string "oss"
.byte 0x1 .byte 0x1
@ -8994,8 +8996,8 @@ _ZTSSs:
.uleb128 0x1 .uleb128 0x1
.byte 0x50 .byte 0x50
.uleb128 0x2 .uleb128 0x2
.byte 0x8f .byte 0x84
.sleb128 40 .sleb128 8
.byte 0 .byte 0
.byte 0 .byte 0
.uleb128 0x7a .uleb128 0x7a
@ -9010,12 +9012,12 @@ _ZTSSs:
.uleb128 0x1 .uleb128 0x1
.byte 0x50 .byte 0x50
.uleb128 0x2 .uleb128 0x2
.byte 0x8f .byte 0x84
.sleb128 32 .sleb128 0
.byte 0 .byte 0
.uleb128 0x7b .uleb128 0x7b
.8byte .LVL3 .8byte .LVL3
.4byte 0x517e .4byte 0x5171
.4byte 0x501a .4byte 0x501a
.uleb128 0x79 .uleb128 0x79
.uleb128 0x1 .uleb128 0x1
@ -9025,14 +9027,8 @@ _ZTSSs:
.byte 0 .byte 0
.uleb128 0x7b .uleb128 0x7b
.8byte .LVL6 .8byte .LVL6
.4byte 0x5192 .4byte 0x5185
.4byte 0x503f .4byte 0x5032
.uleb128 0x79
.uleb128 0x1
.byte 0x51
.uleb128 0x9
.byte 0x3
.8byte _ZTISs
.uleb128 0x79 .uleb128 0x79
.uleb128 0x1 .uleb128 0x1
.byte 0x50 .byte 0x50
@ -9041,9 +9037,9 @@ _ZTSSs:
.sleb128 0 .sleb128 0
.byte 0 .byte 0
.uleb128 0x7b .uleb128 0x7b
.8byte .LVL7 .8byte .LVL8
.4byte 0x51ac .4byte 0x519f
.4byte 0x5057 .4byte 0x504a
.uleb128 0x79 .uleb128 0x79
.uleb128 0x1 .uleb128 0x1
.byte 0x50 .byte 0x50
@ -9052,7 +9048,7 @@ _ZTSSs:
.sleb128 0 .sleb128 0
.byte 0 .byte 0
.uleb128 0x7c .uleb128 0x7c
.8byte .LVL9 .8byte .LVL12
.uleb128 0x79 .uleb128 0x79
.uleb128 0x1 .uleb128 0x1
.byte 0x50 .byte 0x50
@ -9062,8 +9058,8 @@ _ZTSSs:
.byte 0 .byte 0
.byte 0 .byte 0
.uleb128 0x78 .uleb128 0x78
.8byte .LVL10 .8byte .LVL13
.4byte 0x51bc .4byte 0x51af
.uleb128 0x79 .uleb128 0x79
.uleb128 0x1 .uleb128 0x1
.byte 0x50 .byte 0x50
@ -9073,10 +9069,10 @@ _ZTSSs:
.byte 0 .byte 0
.byte 0 .byte 0
.uleb128 0x10 .uleb128 0x10
.4byte 0x5082 .4byte 0x5075
.uleb128 0x55 .uleb128 0x55
.byte 0x8 .byte 0x8
.4byte 0x5088 .4byte 0x507b
.uleb128 0x10 .uleb128 0x10
.4byte 0x4872 .4byte 0x4872
.uleb128 0x7d .uleb128 0x7d
@ -9088,9 +9084,9 @@ _ZTSSs:
.8byte .LFE1300-.LFB1300 .8byte .LFE1300-.LFB1300
.uleb128 0x1 .uleb128 0x1
.byte 0x9c .byte 0x9c
.4byte 0x50c7 .4byte 0x50ba
.uleb128 0x78 .uleb128 0x78
.8byte .LVL11 .8byte .LVL14
.4byte 0x4f63 .4byte 0x4f63
.uleb128 0x7e .uleb128 0x7e
.uleb128 0x1 .uleb128 0x1
@ -9165,13 +9161,13 @@ _ZTSSs:
.uleb128 0x86 .uleb128 0x86
.4byte .LASF799 .4byte .LASF799
.4byte 0x20d .4byte 0x20d
.4byte 0x5192 .4byte 0x5185
.uleb128 0x19 .uleb128 0x19
.4byte 0x221 .4byte 0x221
.byte 0 .byte 0
.uleb128 0x87 .uleb128 0x87
.4byte .LASF801 .4byte .LASF801
.4byte 0x51ac .4byte 0x519f
.uleb128 0x19 .uleb128 0x19
.4byte 0x20d .4byte 0x20d
.uleb128 0x19 .uleb128 0x19
@ -9181,7 +9177,7 @@ _ZTSSs:
.byte 0 .byte 0
.uleb128 0x87 .uleb128 0x87
.4byte .LASF802 .4byte .LASF802
.4byte 0x51bc .4byte 0x51af
.uleb128 0x19 .uleb128 0x19
.4byte 0x20d .4byte 0x20d
.byte 0 .byte 0
@ -11207,16 +11203,30 @@ _ZTSSs:
.8byte 0 .8byte 0
.LLST1: .LLST1:
.8byte .LVL4-.Ltext0 .8byte .LVL4-.Ltext0
.8byte .LVL8-.Ltext0 .8byte .LVL7-.Ltext0
.2byte 0x1
.byte 0x64
.8byte .LVL7-.Ltext0
.8byte .LVL9-.Ltext0
.2byte 0x3 .2byte 0x3
.byte 0x8f .byte 0x8f
.sleb128 32 .sleb128 32
.byte 0x9f .byte 0x9f
.8byte .LVL8-.Ltext0 .8byte .LVL9-.Ltext0
.8byte .LVL9-1-.Ltext0 .8byte .LVL10-.Ltext0
.2byte 0x1
.byte 0x64
.8byte .LVL10-.Ltext0
.8byte .LVL11-.Ltext0
.2byte 0x3
.byte 0x8f
.sleb128 32
.byte 0x9f
.8byte .LVL11-.Ltext0
.8byte .LVL12-1-.Ltext0
.2byte 0x1 .2byte 0x1
.byte 0x50 .byte 0x50
.8byte .LVL9-1-.Ltext0 .8byte .LVL12-1-.Ltext0
.8byte .LFE1299-.Ltext0 .8byte .LFE1299-.Ltext0
.2byte 0x3 .2byte 0x3
.byte 0x8f .byte 0x8f
@ -11377,8 +11387,6 @@ _ZTSSs:
.string "tm_isdst" .string "tm_isdst"
.LASF654: .LASF654:
.string "grouping" .string "grouping"
.LASF804:
.string "GNU C++ 4.8.4 -g -O1 -std=c++11 -fstack-protector"
.LASF20: .LASF20:
.string "_lock" .string "_lock"
.LASF107: .LASF107:
@ -12523,6 +12531,8 @@ _ZTSSs:
.string "_ZNKSs17find_first_not_ofERKSsm" .string "_ZNKSs17find_first_not_ofERKSsm"
.LASF30: .LASF30:
.string "__FILE" .string "__FILE"
.LASF804:
.string "GNU C++ 4.8.4 -g -O1 -std=c++11 -fPIE -fstack-protector"
.LASF247: .LASF247:
.string "_ZNSspLESt16initializer_listIcE" .string "_ZNSspLESt16initializer_listIcE"
.LASF587: .LASF587:

View File

@ -19,7 +19,7 @@
$ g++ --version $ g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
$ g++ entry-value-typedef.cpp -O1 -S -g -o entry-value-typedef-amd64.S $ g++ entry-value-typedef.cpp -O1 -fPIE -S -g -o entry-value-typedef-amd64.S
*/ */
.file "entry-value-typedef.cpp" .file "entry-value-typedef.cpp"
@ -13647,8 +13647,6 @@ _ZTINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE:
.section .debug_str,"MS",@progbits,1 .section .debug_str,"MS",@progbits,1
.LASF739: .LASF739:
.string "int_p_sep_by_space" .string "int_p_sep_by_space"
.LASF920:
.string "GNU C++14 9.4.0 -mtune=generic -march=x86-64 -g -O1 -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -fcf-protection"
.LASF547: .LASF547:
.string "char" .string "char"
.LASF487: .LASF487:
@ -15399,6 +15397,8 @@ _ZTINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE:
.string "__int_least8_t" .string "__int_least8_t"
.LASF495: .LASF495:
.string "base" .string "base"
.LASF920:
.string "GNU C++14 9.4.0 -mtune=generic -march=x86-64 -g -O1 -fPIE -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -fcf-protection"
.LASF17: .LASF17:
.string "const_pointer" .string "const_pointer"
.LASF764: .LASF764: