From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4D94B388A839; Fri, 28 Aug 2020 10:27:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D94B388A839 From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug breakpoints/26546] New: [pie] Setting breakpoint on missing label sets breakpoint at offset 0 in NULL section Date: Fri, 28 Aug 2020 10:27:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: breakpoints X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2020 10:27:36 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26546 Bug ID: 26546 Summary: [pie] Setting breakpoint on missing label sets breakpoint at offset 0 in NULL section Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: breakpoints Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- Say we modify test-case label-without-address.exp like this: ... diff --git a/gdb/testsuite/gdb.base/label-without-address.exp b/gdb/testsui= te/g db.base/label-without-address.exp index 0fcb1fd19a..2f05099f3a 100644 --- a/gdb/testsuite/gdb.base/label-without-address.exp +++ b/gdb/testsuite/gdb.base/label-without-address.exp @@ -19,6 +19,15 @@ if {[prepare_for_testing "failed to prepare" $testfile=20 $srcfile debug]} { return -1 } +gdb_test "p main" + +if ![runto_main] then { + fail "can't run to main" + return 0 +} + +gdb_test "p main" + set supported 0 gdb_test_multiple "l main:L1" "" { -wrap -re "No label \"L1\" defined in function \"main\"\." { ... and run with target_board unix/-fPIE/-pie, we get: ... (gdb) break main:L1^M Breakpoint 2 at 0x555555554000: file label-without-address.c, line 22.^M ... Looking at the addresses of main before: (gdb) p main^M $1 =3D {int (void)} 0x63a
^M ... and after relocation: ... (gdb) p main^M $2 =3D {int (void)} 0x55555555463a
^M ... it becomes obvious that 0x55555555463a - 0x63a =3D=3D 0x555555554000 is the relocation base, so we're setting a breakpoint at offset 0, in the NULL section: ... $ readelf -S outputs/gdb.base/label-without-address/label-without-address= =20=20=20=20=20=20=20 There are 37 section headers, starting at offset 0x2948: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 ... Indeed, the label has no address: ... <2><115>: Abbrev Number: 3 (DW_TAG_label) <116> DW_AT_name : L1 <119> DW_AT_decl_file : 1 <11a> DW_AT_decl_line : 22 <2><11b>: Abbrev Number: 0 ... and the line number doesn't match anything: ... CU: /home/vries/gdb_versions/devel/src/gdb/testsuite/gdb.base/label-without-add= ress.c: File name Line number Starting address Vie= w=20=20=20 Stmt label-without-address.c 20 0x63a=20=20= =20=20=20=20=20=20=20=20=20 x label-without-address.c 21 0x63e=20=20= =20=20=20=20=20=20=20=20=20 x label-without-address.c 24 0x643=20=20= =20=20=20=20=20=20=20=20=20 x label-without-address.c - 0x645 ... --=20 You are receiving this mail because: You are on the CC list for the bug.=