diff mbox

[U-Boot,RFC] Fix build problems caused by "_end" -> "__bss_end__" rename

Message ID 1301301631-6115-1-git-send-email-wd@denx.de
State Superseded
Headers show

Commit Message

Wolfgang Denk March 28, 2011, 8:40 a.m. UTC
Commit 44c6e65 "rename _end to __bss_end__ broke building of a large
number of systems (at least all PowerPC?):

libstubs.o: In function `app_startup':
examples/standalone/stubs.c:197: undefined reference to `__bss_end__'

As a workaround (instead of introducing linker scripts) we can
add a --defsym=__bss_end__=_end

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Po-Yu Chuang <ratbert@faraday-tech.com>
Cc: Albert Aribaud <albert.aribaud@free.fr>
---


What I really do not understand is why we don't see the same type of
undefined reference errors on ARM?  ALso, on ARM we see __bss_end__
and _bss_end__, and __bss_start und __bss_start__ - where are the
other names coming from? [On PPC we see only __bss_start and
__bss_end__].

 examples/standalone/Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Po-Yu Chuang March 28, 2011, 8:48 a.m. UTC | #1
Hi Wolfgang,

On Mon, Mar 28, 2011 at 4:40 PM, Wolfgang Denk <wd@denx.de> wrote:
> Commit 44c6e65 "rename _end to __bss_end__ broke building of a large
> number of systems (at least all PowerPC?):
>
> libstubs.o: In function `app_startup':
> examples/standalone/stubs.c:197: undefined reference to `__bss_end__'
>
> As a workaround (instead of introducing linker scripts) we can
> add a --defsym=__bss_end__=_end
>
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Cc: Po-Yu Chuang <ratbert@faraday-tech.com>
> Cc: Albert Aribaud <albert.aribaud@free.fr>
> ---
>
>
> What I really do not understand is why we don't see the same type of
> undefined reference errors on ARM?  ALso, on ARM we see __bss_end__
> and _bss_end__, and __bss_start und __bss_start__ - where are the
> other names coming from? [On PPC we see only __bss_start and
> __bss_end__].

Do you mean _end here? If there is __bss_end__ on PPC, then there is
no problem, right?

>  examples/standalone/Makefile |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
> index c1dfdce..06cf14f 100644
> --- a/examples/standalone/Makefile
> +++ b/examples/standalone/Makefile
> @@ -96,6 +96,7 @@ $(LIB):       $(obj).depend $(LIBOBJS)
>  $(ELF):
>  $(obj)%:       $(obj)%.o $(LIB)
>                $(LD) -g -Ttext $(STANDALONE_LOAD_ADDR) \
> +                       --defsym=__bss_end__=_end \
>                        -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
>                        -L$(gcclibdir) -lgcc
>
> --
> 1.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
Wolfgang Denk March 28, 2011, 8:54 a.m. UTC | #2
Dear Po-Yu Chuang,

In message <AANLkTin6cEHSQSquvocW_kXr4-dbtnUGu9XZzEJiTdJ_@mail.gmail.com> you wrote:
> 
> > What I really do not understand is why we don't see the same type of
> > undefined reference errors on ARM? =C2=A0ALso, on ARM we see __bss_end__
> > and _bss_end__, and __bss_start und __bss_start__ - where are the
> > other names coming from? [On PPC we see only __bss_start and
> > __bss_end__].
> 
> Do you mean _end here? If there is __bss_end__ on PPC, then there is
> no problem, right?

No, I mean exactly what I wrote. On PPC I do not see any _end (with
your previous patch), only the symbols defined in the linker script.


Best regards,

Wolfgang Denk
Po-Yu Chuang March 28, 2011, 9:07 a.m. UTC | #3
Hi Wolfgang,

On Mon, Mar 28, 2011 at 4:54 PM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Po-Yu Chuang,
>
> In message <AANLkTin6cEHSQSquvocW_kXr4-dbtnUGu9XZzEJiTdJ_@mail.gmail.com> you wrote:
>>
>> > What I really do not understand is why we don't see the same type of
>> > undefined reference errors on ARM? =C2=A0ALso, on ARM we see __bss_end__
>> > and _bss_end__, and __bss_start und __bss_start__ - where are the
>> > other names coming from? [On PPC we see only __bss_start and
>> > __bss_end__].
>>
>> Do you mean _end here? If there is __bss_end__ on PPC, then there is
>> no problem, right?
>
> No, I mean exactly what I wrote. On PPC I do not see any _end (with
> your previous patch), only the symbols defined in the linker script.

All those symbols come from default linker script in one of
${toolchain}/arm-none-linux-gnueabi/lib/ldscripts/armelfb_linux_eabi.*.

It defines __bss_start, __bss_start__, _bss_end__ and __bss_end__.
Is ARM the only platform doing this?

Best regards,
Po-Yu Chuang
Wolfgang Denk March 28, 2011, 10:25 a.m. UTC | #4
Dear Po-Yu Chuang,

In message <AANLkTik-a8oL2CEnb3wf43uwd0r0MGCy8Nnu5DmTWwzw@mail.gmail.com> you wrote:
> 
> > No, I mean exactly what I wrote. On PPC I do not see any _end (with
> > your previous patch), only the symbols defined in the linker script.
> 
> All those symbols come from default linker script in one of
> ${toolchain}/arm-none-linux-gnueabi/lib/ldscripts/armelfb_linux_eabi.*.
> 
> It defines __bss_start, __bss_start__, _bss_end__ and __bss_end__.
> Is ARM the only platform doing this?

No. Not even ARM is doing this in general. It's your specific tool
chain that does it this way.

It appears that ARM has both *bss_start* and *bss_end*, while PPC has
only __bss_start (and __sbss_start and ___sbss_start), but no
*bss_end (there are __sbss_end and ___sbss_end, though).

I have no idea if there is any rationale for this inconsistency or if
it's a bug.


Verified with both ELDK 4.2 and recent Yocto/Poky tool chains.

Best regards,

Wolfgang Denk
Albert ARIBAUD March 28, 2011, 4:42 p.m. UTC | #5
Le 28/03/2011 10:40, Wolfgang Denk a écrit :
> Commit 44c6e65 "rename _end to __bss_end__ broke building of a large
> number of systems (at least all PowerPC?):
>
> libstubs.o: In function `app_startup':
> examples/standalone/stubs.c:197: undefined reference to `__bss_end__'
>
> As a workaround (instead of introducing linker scripts) we can
> add a --defsym=__bss_end__=_end
>
> Signed-off-by: Wolfgang Denk<wd@denx.de>
> Cc: Po-Yu Chuang<ratbert@faraday-tech.com>
> Cc: Albert Aribaud<albert.aribaud@free.fr>
> ---

Hmm... The change from _end to __bss_end__ should not have been applied 
to the standalone apps, I believe. They are not compiled with start.S 
but with the standard lib, which will use _end.

> What I really do not understand is why we don't see the same type of
> undefined reference errors on ARM?  ALso, on ARM we see __bss_end__
> and _bss_end__, and __bss_start und __bss_start__ - where are the
> other names coming from? [On PPC we see only __bss_start and
> __bss_end__].

I believe these come from the toolchain's standard lib.

Amicalement,
Wolfgang Denk March 29, 2011, 12:39 p.m. UTC | #6
Dear Albert ARIBAUD,

In message <4D90BA8B.3080200@free.fr> you wrote:
>
> > Commit 44c6e65 "rename _end to __bss_end__ broke building of a large
> > number of systems (at least all PowerPC?):
> >
> > libstubs.o: In function `app_startup':
> > examples/standalone/stubs.c:197: undefined reference to `__bss_end__'
...
> Hmm... The change from _end to __bss_end__ should not have been applied 
> to the standalone apps, I believe. They are not compiled with start.S 
> but with the standard lib, which will use _end.

Good point.  Will send an updated patch.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index c1dfdce..06cf14f 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -96,6 +96,7 @@  $(LIB):	$(obj).depend $(LIBOBJS)
 $(ELF):
 $(obj)%:	$(obj)%.o $(LIB)
 		$(LD) -g -Ttext $(STANDALONE_LOAD_ADDR) \
+			--defsym=__bss_end__=_end \
 			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
 			-L$(gcclibdir) -lgcc