[llvm-dev] workaround to force LLD to make dwarf info sections mappable/loadable? (original) (raw)
Andrew Kelley via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 4 09:00:01 PST 2018
- Previous message: [llvm-dev] workaround to force LLD to make dwarf info sections mappable/loadable?
- Next message: [llvm-dev] LLVM Weekly - #257, December 3rd 2018
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 12/3/18 5:30 PM, Andrew Kelley via llvm-dev wrote:
One more thing - this project as it currently exists is a proof of concept of how a bare bones embedded system executable running on bare metal can still have the same advanced debugging capabilities as when using, e.g. Linux. If the debug info can be directly mapped, and thus eliminate a dependency on a file system or on a special bootloader, it's a great demo.
Here's a working proof of concept.
Source: https://github.com/andrewrk/clashos/tree/bf8e57ac220715d0698ab910d337ea590c4b4e33
Screenshot: https://i.imgur.com/8C1tYys.png
Copy pasted text output: [nix-shell:~/dev/clashos]$ zig build qemu ClashOS 0.0
!KERNEL PANIC! integer overflow /home/andy/dev/clashos/src/serial.zig:99:7: 0x1b10 in ??? (clashos) x += 1; ^ /home/andy/dev/clashos/src/main.zig:58:16: 0x1110 in ??? (clashos) serial.boom(); ^ /home/andy/dev/clashos/src/main.zig:67:18: 0xecc in ??? (clashos) some_function(); ^ ???:?:?: 0x1c in ??? (???)
linker script snippet:
.rodata : ALIGN(4K) {
*(.rodata)
__debug_info_start = .;
KEEP(*(.debug_info))
__debug_info_end = .;
__debug_abbrev_start = .;
KEEP(*(.debug_abbrev))
__debug_abbrev_end = .;
__debug_str_start = .;
KEEP(*(.debug_str))
__debug_str_end = .;
__debug_line_start = .;
KEEP(*(.debug_line))
__debug_line_end = .;
__debug_ranges_start = .;
KEEP(*(.debug_ranges))
__debug_ranges_end = .;
}
LLD patch (submitted upstream at https://reviews.llvm.org/D55276):
--- a/deps/lld/ELF/OutputSections.cpp +++ b/deps/lld/ELF/OutputSections.cpp @@ -95,7 +95,7 @@ void OutputSection::addSection(InputSection *IS) { Flags = IS->Flags; } else { // Otherwise, check if new type or flags are compatible with existing ones.
- unsigned Mask = SHF_ALLOC | SHF_TLS | SHF_LINK_ORDER;
- unsigned Mask = SHF_TLS | SHF_LINK_ORDER; if ((Flags & Mask) != (IS->Flags & Mask)) error("incompatible section flags for " + Name + "\n>>> " + toString(IS) + ": 0x" + utohexstr(IS->Flags) + "\n>>> output section " +
Name +
-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181204/e0b28b48/attachment.sig>
- Previous message: [llvm-dev] workaround to force LLD to make dwarf info sections mappable/loadable?
- Next message: [llvm-dev] LLVM Weekly - #257, December 3rd 2018
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]