http://sourceware.org/bugzilla/show_bug.cgi?id=12763
Summary: [PATCH] Incorrect error when .tbss starts outside PT_LOAD segment Product: binutils Version: 2.20 Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassig...@sources.redhat.com ReportedBy: mar...@mc.pp.se It can happen that .tbss has a VMA which is after the last VMA of the PT_LOAD segment it is in, for example due to alignment requirements. This will cause ld to report an error "`.tbss' can't be allocated in segment". But the check is actually bogus, because the VMA of .tbss is never used. As long as .tbss firs in the PT_TLS segment, all is well. There is already an exception in the macro ELF_SECTION_SIZE, which says that the size of .tbss should not be considered when the segment is PT_LOAD. Well, neither should the VMA. My suggested fix is the following, which leverages the already implemented special handling for .tbss: diff --git a/include/elf/internal.h b/include/elf/internal.h index 9ea175c..0ce9385 100644 --- a/include/elf/internal.h +++ b/include/elf/internal.h @@ -316,6 +316,7 @@ struct elf_segment_map /* SHF_ALLOC sections must have VMAs within the segment. Be careful about segments right at the end of memory. */ \ && ((sec_hdr->sh_flags & SHF_ALLOC) == 0 \ + || ELF_SECTION_SIZE(sec_hdr,segment) == 0 \ || (sec_hdr->sh_addr >= segment->p_vaddr && (sec_hdr->sh_addr - segment->p_vaddr \ + ELF_SECTION_SIZE(sec_hdr, segment) <= segment->p_memsz)))) The rationale here is that if the section has zero size (either becase it's actually empty, or because we are ignoring the size because it's .tbbs in PT_LOAD), then the VMA does not matter, because the address space is empty anyway. The bug exists in both 2.20.1 and 2.21. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils