mirror of
https://github.com/golang/go
synced 2024-11-24 11:20:07 -07:00
debug/elf: ajdust SectionOverlap test for proper fields
The current SectionOverlap tests Size (addr) with Offset (file) This CL set this test for overlap of Size + Addr and Offset + FileSize Fixes #51939 Change-Id: Ied4c0b87f61c4d5e52139a8295c371f55abc776f Reviewed-on: https://go-review.googlesource.com/c/go/+/395920 Trust: mzh <mzh@golangcn.org> Trust: Than McIntosh <thanm@google.com> Run-TryBot: mzh <mzh@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
a4ffeb9edd
commit
baf6df06c0
@ -913,14 +913,32 @@ func TestNoSectionOverlaps(t *testing.T) {
|
|||||||
if sih.Type == SHT_NOBITS {
|
if sih.Type == SHT_NOBITS {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// checking for overlap in file
|
||||||
for j, sj := range f.Sections {
|
for j, sj := range f.Sections {
|
||||||
sjh := sj.SectionHeader
|
sjh := sj.SectionHeader
|
||||||
if i == j || sjh.Type == SHT_NOBITS || sih.Offset == sjh.Offset && sih.Size == 0 {
|
if i == j || sjh.Type == SHT_NOBITS || sih.Offset == sjh.Offset && sih.FileSize == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if sih.Offset >= sjh.Offset && sih.Offset < sjh.Offset+sjh.Size {
|
if sih.Offset >= sjh.Offset && sih.Offset < sjh.Offset+sjh.FileSize {
|
||||||
t.Errorf("ld produced ELF with section %s within %s: 0x%x <= 0x%x..0x%x < 0x%x",
|
t.Errorf("ld produced ELF with section offset %s within %s: 0x%x <= 0x%x..0x%x < 0x%x",
|
||||||
sih.Name, sjh.Name, sjh.Offset, sih.Offset, sih.Offset+sih.Size, sjh.Offset+sjh.Size)
|
sih.Name, sjh.Name, sjh.Offset, sih.Offset, sih.Offset+sih.FileSize, sjh.Offset+sjh.FileSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if sih.Flags&SHF_ALLOC == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// checking for overlap in address space
|
||||||
|
for j, sj := range f.Sections {
|
||||||
|
sjh := sj.SectionHeader
|
||||||
|
if i == j || sjh.Flags&SHF_ALLOC == 0 || sjh.Type == SHT_NOBITS ||
|
||||||
|
sih.Addr == sjh.Addr && sih.Size == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if sih.Addr >= sjh.Addr && sih.Addr < sjh.Addr+sjh.Size {
|
||||||
|
t.Errorf("ld produced ELF with section address %s within %s: 0x%x <= 0x%x..0x%x < 0x%x",
|
||||||
|
sih.Name, sjh.Name, sjh.Addr, sih.Addr, sih.Addr+sih.Size, sjh.Addr+sjh.Size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user