This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: binutils-2.18 and U-Boot
- From: Clemens Koller <clemens dot koller at anagramm dot de>
- To: raptorbrino at aim dot com
- Cc: binutils at sourceware dot org
- Date: Tue, 11 Dec 2007 11:58:31 +0100
- Subject: Re: binutils-2.18 and U-Boot
- References: <8CA09B91B5CF6EC-9F0-31A6@webmail-db07.sysops.aol.com>
Hi, Brian!
raptorbrino@aim.com schrieb:
> I ran into 2 problems linking u-boot with binutils-2.18 for a powerpc-eabi
> target. I need help with the first problem. The second problem I fixed
> and resolves bug 5205.
I'm still around (opened that bug) and can help to test and ACK/NACK your
changes. However, I'm not a linker script as well as binutils whizz, but
have a machine here to verify this problem.
> Problem 1:
> Two segments are produced in linking u-boot. The first segment begins at
> address 0xfff80000 and is size 0x8a400. This segment wraps past the
> end of memory (0xfff80000 + 0x8a400 = 0x0000a400) and causes a link error
> of the form "section .text can't be allocated in segment 0". This error
> makes sense. However, the .bss segment is what's pushing the size past
> the end of memory. The .bss section is size 0x50100. We don't want the
> .bss section to be stored in the image since u-boot is stored in flash at
> 0xfff80000 and then copies itself to RAM in low memory, such as address
> 0x0, fills out the GOT for data and bss access, and zeroes the .bss
> itself. How can we avoid the above error message? The error is generated
> from line 4362 in elf.c in the binutils-2.18 release. I don't quite
> understand the intention of the error check. In looking at it, the error
> check is only done if the segment is a LOAD segment, so should we fill out
> a PHDR table and put the .bss section in a no load phdr? If it's only done
> for a LOAD segment, that would suggest the check shouldn't include NOLOAD
> sections. However, putting a NOLOAD in the link script for the .bss
> section
> still has the error. I guess I'm confused whether the link error is due to
> a bug in the code or something I need to modify in the link script or it's
> just invliad to have the .bss wrap off memory? Thanks for any help.
>
> Problem 2:
> The other segment produced in linking u-boot begins at address 0xfffff000
> and is of size 0x1000. This segment produces a link error, also generated
> from line 4362 in elf.c, "section .prog can't be allocated in segment 1".
> However, in this scenario all sections definitely fit within the segment,
> but the macro ELF_IS_SECTION_IN_SEGMENT always returns 0. This is because
> the macro checks, among other things, whether (section address +
> section size <= segment address + segment size). Segment address + segment
> size is 0 because it wraps (0xfffff000 + 0x1000 = 0), so the check never
> passes. The fix is below. I'm new at this, can I simply check it in or
> do I need to follow a special process? Also, this bug has been reported as
> bug 5205 http://www.sourceware.org/bugzilla/show_bug.cgi?id=5205. Can I
> mark it as fixed, or again, do I need to follow a special process? I
> apologize if the process is posted somewhere, but I can't find it.
Thank you very much for the detailed explanation.
I would prefer to wait for some feedback here if the way you
fixed that bug is okay.
> diff -Naur a/include/elf/internal.h b/include/elf/internal.h
> --- a/include/elf/internal.h 2007-08-06 12:59:47.000000000 -0700
> +++ b/include/elf/internal.h 2007-12-06 18:36:50.062500000 -0800
> @@ -278,13 +278,13 @@
> offset within the segment. */ \
> && (sec_hdr->sh_type == SHT_NOBITS \
> || ((bfd_vma) sec_hdr->sh_offset >= segment->p_offset \
> - && (sec_hdr->sh_offset + ELF_SECTION_SIZE(sec_hdr, segment) \
> - <= segment->p_offset + segment->p_filesz))) \
> + && (sec_hdr->sh_offset + ELF_SECTION_SIZE(sec_hdr, segment) - 1 \
> + <= segment->p_offset + segment->p_filesz - 1))) \
> /* SHF_ALLOC sections must have VMAs within the segment. */ \
> && ((sec_hdr->sh_flags & SHF_ALLOC) == 0 \
> || (sec_hdr->sh_addr >= segment->p_vaddr \
> - && (sec_hdr->sh_addr + ELF_SECTION_SIZE(sec_hdr, segment) \
> - <= segment->p_vaddr + segment->p_memsz))))
> + && (sec_hdr->sh_addr + ELF_SECTION_SIZE(sec_hdr, segment) - 1 \
> + <= segment->p_vaddr + segment->p_memsz - 1))))
>
> /* Decide if the given sec_hdr is in the given segment in file. */
> #define ELF_IS_SECTION_IN_SEGMENT_FILE(sec_hdr, segment)
Give me a day or two to test this patch.
Regards,
--
Clemens Koller
__________________________________
R&D Imaging Devices
Anagramm GmbH
Rupert-Mayer-Straße 45/1
Linhof Werksgelände
D-81379 München
Tel.089-741518-50
Fax 089-741518-19
http://www.anagramm-technology.com