Skip to content

Commit 56b5365

Browse files
author
Alex B
committed
Address Feedback nr4: error checks; llvm-readelf; fix comments; etc...
1 parent 43dbc80 commit 56b5365

File tree

4 files changed

+41
-24
lines changed

4 files changed

+41
-24
lines changed

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ void MCAsmStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
17721772

17731773
void MCAsmStreamer::emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name) {
17741774
MCStreamer::emitDwarfLocLabelDirective(Loc, Name);
1775-
OS << "\t.loc_label " << Name;
1775+
OS << ".loc_label\t" << Name;
17761776
EmitEOL();
17771777
}
17781778

llvm/lib/MC/MCDwarf.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,6 @@ void MCDwarfLineTable::endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS,
281281
// won't actually emit any line information, it will reset the line table
282282
// sequence and emit a label at the start of the new line table sequence.
283283
MCDwarfLineEntry LineEntry(LineSym, DwarfLoc, LineStreamLabel, DefLoc);
284-
285-
// Add the line entry to this section's entries.
286284
getMCLineSections().addLineEntry(LineEntry, MCOS->getCurrentSectionOnly());
287285
}
288286

llvm/lib/MC/MCObjectStreamer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,11 @@ void MCObjectStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
469469
void MCObjectStreamer::emitDwarfLineEndEntry(MCSection *Section,
470470
MCSymbol *LastLabel,
471471
MCSymbol *EndLabel) {
472-
// Emit a DW_LNE_end_sequence for the end of the section.
473-
// Use the section end label to compute the address delta and use INT64_MAX
474-
// as the line delta which is the signal that this is actually a
472+
// Emit a DW_LNE_end_sequence into the line table. When EndLabel is null, it
473+
// means we should emit the entry for the end of the section and therefore we
474+
// use the section end label for the reference label. After having the
475+
// appropriate reference label, we emit the address delta and use INT64_MAX as
476+
// the line delta which is the signal that this is actually a
475477
// DW_LNE_end_sequence.
476478
if (!EndLabel)
477479
EndLabel = endSection(Section);

llvm/test/MC/ELF/debug-loc-label.s

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
// RUN: llvm-mc -filetype obj -triple x86_64-linux-elf %s -o %t.o
55
// RUN: llvm-dwarfdump -v --debug-line %t.o | FileCheck %s --check-prefix=CHECK-LINE-TABLE
6-
// RUN: llvm-objdump -s -j .offset_02 -j .offset_03 -j .offset_05 %t.o | FileCheck %s --check-prefix=CHECK-SECTIONS
6+
// RUN: llvm-readelf -s %t.o | FileCheck %s --check-prefix=CHECK-SYM
7+
// RUN: llvm-objdump -s -j .offsets %t.o | FileCheck %s --check-prefix=CHECK-OFFSETS
8+
9+
// RUN: not llvm-mc -filetype obj -triple x86_64-linux-elf --defsym ERR=1 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
10+
// RUN: not llvm-mc -filetype obj -triple x86_64-linux-elf --defsym ERR2=1 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2 --implicit-check-not=error:
711

812

913

@@ -34,18 +38,23 @@
3438
# CHECK-LINE-TABLE-NEXT: 0x00000069: 05 DW_LNS_set_column (5)
3539
# CHECK-LINE-TABLE-NEXT: 0x0000006b: 01 DW_LNS_copy
3640
# CHECK-LINE-TABLE-NEXT: 0x0000000000000018 1 5 1 0 0 0 is_stmt
37-
# CHECK-LINE-TABLE-NEXT: 0x0000006c: 02 DW_LNS_advance_pc (addr += 9, op-index += 0)
38-
# CHECK-LINE-TABLE-NEXT: 0x0000006e: 00 DW_LNE_end_sequence
39-
# CHECK-LINE-TABLE-NEXT: 0x0000000000000021 1 5 1 0 0 0 is_stmt end_sequence
41+
# CHECK-LINE-TABLE-NEXT: 0x0000006c: 00 DW_LNE_end_sequence
42+
# CHECK-LINE-TABLE-NEXT: 0x0000000000000018 1 5 1 0 0 0 is_stmt end_sequence
4043

41-
# CHECK-SECTIONS: Contents of section .offset_02:
42-
# CHECK-SECTIONS-NEXT: 0000 39000000
44+
# CHECK-SYM: Symbol table '.symtab' contains 9 entries:
45+
# CHECK-SYM-NEXT: Num: Value Size Type Bind Vis Ndx Name
46+
# CHECK-SYM-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
47+
# CHECK-SYM-NEXT: 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.c
48+
# CHECK-SYM-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 .text
49+
# CHECK-SYM-NEXT: 3: 0000000000000039 0 NOTYPE LOCAL DEFAULT 3 my_label_02
50+
# CHECK-SYM-NEXT: 4: 000000000000004a 0 NOTYPE LOCAL DEFAULT 3 my_label_03
51+
# CHECK-SYM-NEXT: 5: 000000000000005b 0 NOTYPE LOCAL DEFAULT 3 my_label_04
52+
# CHECK-SYM-NEXT: 6: 000000000000004a 0 NOTYPE LOCAL DEFAULT 3 my_label_03.1
53+
# CHECK-SYM-NEXT: 7: 000000000000006f 0 NOTYPE LOCAL DEFAULT 3 my_label_05
54+
# CHECK-SYM-NEXT: 8: 0000000000000000 0 FUNC GLOBAL DEFAULT 2 foo
4355

44-
# CHECK-SECTIONS: Contents of section .offset_03:
45-
# CHECK-SECTIONS-NEXT: 0000 4a000000
56+
# CHECK-OFFSETS: 0000 39000000 4a000000 5b000000
4657

47-
# CHECK-SECTIONS: Contents of section .offset_05:
48-
# CHECK-SECTIONS-NEXT: 0000 5b000000
4958
.text
5059
.file "test.c"
5160
.globl foo
@@ -67,18 +76,26 @@ foo:
6776
.loc 1 1 4
6877
.loc_label my_label_04
6978
.loc 1 1 5
79+
.ifdef ERR
80+
.loc_label my_label_04
81+
# ERR: [[#@LINE+1]]:13: error: expected identifier
82+
.loc_label
83+
# ERR: [[#@LINE+1]]:19: error: expected newline
84+
.loc_label aaaa bbbb
85+
.endif
86+
.ifdef ERR2
87+
# ERR2: [[#@LINE+1]]:14: error: symbol 'my_label_04' is already defined
88+
.loc_label my_label_04
89+
.endif
7090
mov %rax, 0x04
91+
.loc_label my_label_05
7192
ret
7293
.cfi_endproc
7394

7495
.section .debug_line,"",@progbits
7596
.Lline_table_start0:
7697

77-
.section .offset_02,"",@progbits
78-
.quad my_label_02-.Lline_table_start0
79-
80-
.section .offset_03,"",@progbits
81-
.quad my_label_03-.Lline_table_start0
82-
83-
.section .offset_05,"",@progbits
84-
.quad my_label_04-.Lline_table_start0
98+
.section .offsets,"",@progbits
99+
.long my_label_02-.Lline_table_start0
100+
.long my_label_03-.Lline_table_start0
101+
.long my_label_04-.Lline_table_start0

0 commit comments

Comments
 (0)