[PATCH] D81051: [ObjectYAML][ELF] Let the endianness of DWARF sections be inferred from FileHeader.
Xing GUO via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 06:33:16 PDT 2020
Higuoxing updated this revision to Diff 268168.
Higuoxing marked an inline comment as done.
Higuoxing added a comment.
- Rebase.
- Address comments in D80972 <https://reviews.llvm.org/D80972>.
- Remove spaces between dashes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81051/new/
https://reviews.llvm.org/D81051
Files:
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml
===================================================================
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml
@@ -4,8 +4,8 @@
## Generate and verify a big endian object file.
-# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.o
-# RUN: llvm-readobj --sections --section-data %t1.o | \
+# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t.be.o
+# RUN: llvm-readobj --sections --section-data %t.be.o | \
# RUN: FileCheck %s -DADDRALIGN=1 -DSIZE=96 --check-prefixes=DWARF-BE-HEADER,DWARF-BE-CONTENT
# DWARF-BE-HEADER: Index: 1
@@ -90,6 +90,67 @@
- Address: 0x0000000056780000
Length: 0x10
+## Generate and verify a little endian object file.
+
+# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t.le.o
+# RUN: llvm-readobj --sections --section-data %t.le.o | \
+# RUN: FileCheck %s --check-prefixes=DWARF-LE-DEFAULT
+
+# DWARF-LE-DEFAULT: Section {
+# DWARF-LE-DEFAULT: Index: 1
+# DWARF-LE-DEFAULT-NEXT: Name: .debug_aranges (1)
+# DWARF-LE-DEFAULT-NEXT: Type: SHT_PROGBITS (0x1)
+# DWARF-LE-DEFAULT-NEXT: Flags [ (0x0)
+# DWARF-LE-DEFAULT-NEXT: ]
+# DWARF-LE-DEFAULT-NEXT: Address: 0x0
+# DWARF-LE-DEFAULT-NEXT: Offset: 0x40
+# DWARF-LE-DEFAULT-NEXT: Size: 96
+# DWARF-LE-DEFAULT-NEXT: Link: 0
+# DWARF-LE-DEFAULT-NEXT: Info: 0
+# DWARF-LE-DEFAULT-NEXT: AddressAlignment: 1
+# DWARF-LE-DEFAULT-NEXT: EntrySize: 0
+# DWARF-LE-DEFAULT-NEXT: SectionData (
+# DWARF-LE-DEFAULT-NEXT: 0000: 2C000000 02000000 00000400 00000000
+## | | | | | |
+## | | | | | +------- Padding zeros (4-byte)
+## | | | | +- SegSize (1-byte) 0x00
+## | | | +- AddrSize (1-byte) 0x04
+## | | +-------- CuOffset (4-byte) 0x00
+## | +--- Version (2-byte) 0x02
+## +------- InitialLength (4-byte) 0x2c
+##
+# DWARF-LE-DEFAULT-NEXT: 0010: 34120000 20000000 00000000 00000000
+## | | |
+## | | +---------------- Terminating Entry
+## | +------- Length (4-byte) 0x20
+## +------- Address (4-byte) 0x1234
+##
+# DWARF-LE-DEFAULT-NEXT: 0020: 2C000000 02006500 00000800 00000000
+## | | | | | |
+## | | | | | +------- Padding zeros (4-byte)
+## | | | | +- SegSize (1-byte) 0x00
+## | | | +- AddrSize (1-byte) 0x08
+## | | +-------- CuOffset (4-byte) 0x00
+## | +--- Version (2-byte) 0x02
+## +------- InitialLength (4-byte) 0x2c
+##
+# DWARF-LE-DEFAULT-NEXT: 0030: 78560000 00000000 20000000 00000000
+## | |
+## | +---------------- Length (8-byte) 0x20
+## +---------------- Address (8-byte) 0x5678
+##
+# DWARF-LE-DEFAULT-NEXT: 0040: 00007856 00000000 10000000 00000000
+## | |
+## | +---------------- Length (8-byte) 0x10
+## +---------------- Address (8-byte) 0x5678
+##
+# DWARF-LE-DEFAULT-NEXT: 0050: 00000000 00000000 00000000 00000000
+## |
+## +---------------------------------- Terminating entry
+##
+# DWARF-LE-DEFAULT-NEXT: )
+# DWARF-LE-DEFAULT-NEXT: }
+
## b) Generate the .debug_aranges section from raw section content.
# RUN: yaml2obj --docnum=2 %s -o %t2.o
Index: llvm/lib/ObjectYAML/ELFYAML.cpp
===================================================================
--- llvm/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1654,6 +1654,9 @@
IO.mapOptional("Symbols", Object.Symbols);
IO.mapOptional("DynamicSymbols", Object.DynamicSymbols);
IO.mapOptional("DWARF", Object.DWARF);
+ if (Object.DWARF)
+ Object.DWARF->IsLittleEndian =
+ Object.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);
IO.setContext(nullptr);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81051.268168.patch
Type: text/x-patch
Size: 4730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200603/e330aa62/attachment-0001.bin>
More information about the llvm-commits
mailing list