mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
llvm-objdump: Handle BSS sections larger than the object file
The size of the uninitialized sections, like BSS, can exceed the size of the object file. Do not attempt to grab the contents of such sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212953 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -628,8 +628,6 @@ static void PrintSectionContents(const ObjectFile *Obj) {
|
||||
bool BSS;
|
||||
if (error(Section.getName(Name)))
|
||||
continue;
|
||||
if (error(Section.getContents(Contents)))
|
||||
continue;
|
||||
if (error(Section.getAddress(BaseAddr)))
|
||||
continue;
|
||||
if (error(Section.isBSS(BSS)))
|
||||
@ -637,12 +635,18 @@ static void PrintSectionContents(const ObjectFile *Obj) {
|
||||
|
||||
outs() << "Contents of section " << Name << ":\n";
|
||||
if (BSS) {
|
||||
uint64_t Size;
|
||||
if (error(Section.getSize(Size)))
|
||||
continue;
|
||||
outs() << format("<skipping contents of bss section at [%04" PRIx64
|
||||
", %04" PRIx64 ")>\n", BaseAddr,
|
||||
BaseAddr + Contents.size());
|
||||
", %04" PRIx64 ")>\n",
|
||||
BaseAddr, BaseAddr + Size);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (error(Section.getContents(Contents)))
|
||||
continue;
|
||||
|
||||
// Dump out the content as hex and printable ascii characters.
|
||||
for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {
|
||||
outs() << format(" %04" PRIx64 " ", BaseAddr + addr);
|
||||
|
Reference in New Issue
Block a user