[U-Boot] recent tools on FreeBSD
Guilherme Maciel Ferreira
guilherme.maciel.ferreira at gmail.com
Thu Feb 5 13:27:34 CET 2015
Hi Jeroen,
My apologies, I didn't test the tools on BSD. The answers are inline.
Best regards,
Guilherme
Am 04.02.2015 19:37 schrieb "Jeroen Hofstee" <jeroen at myspectrum.nl>:
>
> Hello Guilherme / Simon,
>
> It seems that commit f86ed6a8d52c99bb2d17d3cac1647edca0c4399c,
> "tools: moved code common to all image tools to a separated module."
I guess the culprit is commit a93648d197df48fa46dd55f925ff70468bd81c71,
"imagetool: replace image registration function by linker_lists feature".
Because that commit introduced the linker script to imagetools.
>
> cause some trouble when building on FreeBSD.
>
> /usr/bin/ld:./tools/imagetool.lds:24: syntax error
> cc: error: linker command failed with exit code 1 (use -v to see
invocation)
>
> which is about the last line, /* INSERT BEFORE .data; */
>
> And thereafter about:
> /usr/lib/crt1.o: In function `_start':
> /usr/src/lib/csu/amd64/crt1.c:(.text+0x90): undefined reference to
`__preinit_array_start'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0x95): undefined reference to
`__preinit_array_end'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0xb1): undefined reference to
`__preinit_array_start'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0xb6): undefined reference to
`__preinit_array_end'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0xd4): undefined reference to
`__preinit_array_start'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0xf9): undefined reference to
`__init_array_start'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0xfe): undefined reference to
`__init_array_end'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0x11a): undefined reference to
`__init_array_start'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0x11f): undefined reference to
`__init_array_end'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0x144): undefined reference to
`__init_array_start'
> /usr/lib/crt1.o: In function `finalizer':
> /usr/src/lib/csu/amd64/crt1.c:(.text+0x187): undefined reference to
`__fini_array_start'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0x18c): undefined reference to
`__fini_array_end'
> /usr/src/lib/csu/amd64/crt1.c:(.text+0x1b4): undefined reference to
`__fini_array_start'
> /usr/bin/ld: tools/mkenvimage: hidden symbol `__preinit_array_start'
isn't defined
>
> Which seems to be about missing sections. The (default) ld on FreeBSD
branched of from an old version [1],
> With below patch [2] things build at least.
>
> Some question about this:
> - why do we need linker magic for tools at all? Given that there is no
custom linker script for tools (or I failed
> to find it), this adds a dependency between the host default linker
script and the tweaks in imagetool.lds
The imagetools.lds is there to allow image types (e.g. FIT, Multimage, ...)
to be placed in a linked list built by the linker (called linker list). The
previous linked list that connected the tools (mkimage and dumpimage) with
the image types, required a lot more code. With the linker list, there is
less code, and most of the linked list setup is performed automatically by
the linker. This explains the linker magic :-)
The imagetool.lds file follows the same approach of other ld scripts in
U-Boot, specially those that create a linked list of U-Boot commands.
> - what it the INSERT BEFORE .data supposed to do?
Each image type object file has a .u_boot_list_2_image_type_2 section. This
section has the code to place each image type in the linked list.
The INSERT BEFORE is supposed to place linker list stuff before the .data
section.
> - and last but not least, how can we make this work in general
First, you have to make sure the BSD linker supports the directives in the
ld script (imagetools.lds). Second, you can use the test scripts (next
topic). Third, check if the directives you introduced are not BSD-specific.
> - and really last, how do I test if it works..
There are two scripts to test the image tools, test-imagetools.sh and
test-fit.py. Running those scripts you make sure the linker list is
properly setup, because it is required by the imagetools to find the image
type.
$ make O=sandbox clean
$ make O=sandbox sandbox_config
$ make mrproper
$ make O=sandbox
$ ./test/image/test-imagetools.sh
$ ./test/image/test-fit.py -u sandbox/u-boot
I hope it helps.
>
> With kind regards,
> Jeroen
>
> [1]
> ld --version
> GNU ld 2.17.50 [FreeBSD] 2007-07-03
>
> [2]
> diff --git a/tools/imagetool.lds b/tools/imagetool.ldsdiff --git
a/tools/imagetool.lds b/tools/imagetool.lds
> index 7e92b4a..b18eadb 100644
> --- a/tools/imagetool.lds
> +++ b/tools/imagetool.lds
> @@ -19,6 +19,17 @@ SECTIONS
> __u_boot_sandbox_option_end = .;
>
> __bss_start = .;
> +
> + . = ALIGN(32 / 8);
> + PROVIDE (__preinit_array_start = .);
> + .preinit_array : { *(.preinit_array) }
> + PROVIDE (__preinit_array_end = .);
> + PROVIDE (__init_array_start = .);
> + .init_array : { *(.init_array) }
> + PROVIDE (__init_array_end = .);
> + PROVIDE (__fini_array_start = .);
> + .fini_array : { *(.fini_array) }
> + PROVIDE (__fini_array_end = .);
> }
>
> -INSERT BEFORE .data;
> +/* INSERT BEFORE .data; */
>
More information about the U-Boot
mailing list