public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/26546] New: [pie] Setting breakpoint on missing label sets breakpoint at offset 0 in NULL section
@ 2020-08-28 10:27 vries at gcc dot gnu.org
  2020-08-28 11:33 ` [Bug breakpoints/26546] " vries at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-08-28 10:27 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26546

            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/testsuite/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 
$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 = {int (void)} 0x63a <main>^M
...
and after relocation:
...
(gdb) p main^M
$2 = {int (void)} 0x55555555463a <main>^M
...
it becomes obvious that 0x55555555463a - 0x63a == 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       
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-address.c:
File name                            Line number    Starting address    View   
Stmt
label-without-address.c                       20               0x63a           
   x
label-without-address.c                       21               0x63e           
   x
label-without-address.c                       24               0x643           
   x
label-without-address.c                        -               0x645
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-03 10:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 10:27 [Bug breakpoints/26546] New: [pie] Setting breakpoint on missing label sets breakpoint at offset 0 in NULL section vries at gcc dot gnu.org
2020-08-28 11:33 ` [Bug breakpoints/26546] " vries at gcc dot gnu.org
2020-09-03 10:30 ` cvs-commit at gcc dot gnu.org
2020-09-03 10:31 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).