recent tools on FreeBSD
Hello Guilherme / Simon,
It seems that commit f86ed6a8d52c99bb2d17d3cac1647edca0c4399c, "tools: moved code common to all image tools to a separated module."
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
- what it the INSERT BEFORE .data supposed to do?
- and last but not least, how can we make this work in general
- and really last, how do I test if it works..
With kind regards,
Jeroen
[1]
ld --version
GNU ld 2.17.50 [FreeBSD] 2007-07-03
[2]
tools/imagetool.ldsdiff --git renamed from tools/imagetool.lds +0 -0
a/tools/imagetool.lds b/tools/imagetool.lds
index 7e92b4a..b18eadb 100644
tools/imagetool.lds +12 -1
@@ -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; */
Hi Jeroen,
tools/imagetool.ldsdiff --git
Quoted 66 lines · Jeroen Hofstee
Hello Guilherme / Simon,
It seems that commit
f86ed6a8d52c99bb2d17d3cac1647edca0c4399c, "tools: moved code common to all image tools to a separated module."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 definedWhich 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 inimagetool.lds
- what it the INSERT BEFORE .data supposed to do?
- and last but not least, how can we make this work in general
- and really last, how do I test if it works..With kind regards,
Jeroen[1]
ld --version
GNU ld 2.17.50 [FreeBSD] 2007-07-03[2]
tools/imagetool.ldsdiff --git renamed from tools/imagetool.lds +0
-0
Where is this file?
Quoted 14 lines
a/tools/imagetool.ldsb/tools/imagetool.lds
index 7e92b4a..b18eadb 100644tools/imagetool.lds +5
-0@@ -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 = .);
tools/imagetool.lds SECTIONS · line 35
Quoted 10 lines
tools/imagetool.lds +7
-1+ 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; */
Regards,
Simon
Hi Simon,
Quoted 63 lines · Simon Glass
Hi Jeroen,
Quoted 60 lines · Jeroen Hofstee
Hello Guilherme / Simon,
It seems that commit
f86ed6a8d52c99bb2d17d3cac1647edca0c4399c, "tools: moved code common to all image tools to a separated module."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 definedWhich 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 inimagetool.lds
- what it the INSERT BEFORE .data supposed to do?
- and last but not least, how can we make this work in general
- and really last, how do I test if it works..With kind regards,
Jeroen
Quoted 7 lines
tools/imagetool.ldsdiff --git
Quoted 6 lines
[1]
ld --version
GNU ld 2.17.50 [FreeBSD] 2007-07-03[2]
tools/imagetool.ldsdiff --git renamed from tools/imagetool.lds +0
-0Where is this file?
It is in 2015-04-rc1, see e.g.
http://git.denx.de/?p=u-boot.git;a=blob;f=tools/imagetool.lds;h=7e92b4ac66c811866148540b6c424026ef7abbbc;hb=HEAD
Regards,
Jeroen
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" <[email protected]>:
Quoted 5 lines
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.
Quoted 5 lines
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)
Quoted 6 lines
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'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0x95): undefined reference to
`__preinit_array_end'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0xb1): undefined reference to
`__preinit_array_start'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0xb6): undefined reference to
`__preinit_array_end'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0xd4): undefined reference to
`__preinit_array_start'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0xf9): undefined reference to
`__init_array_start'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0xfe): undefined reference to
`__init_array_end'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0x11a): undefined reference to
`__init_array_start'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0x11f): undefined reference to
`__init_array_end'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0x144): undefined reference to
`__init_array_start'
Quoted 2 lines
/usr/lib/crt1.o: In function `finalizer':
/usr/src/lib/csu/amd64/crt1.c:(.text+0x187): undefined reference to
`__fini_array_start'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0x18c): undefined reference to
`__fini_array_end'
Quoted 1 line
/usr/src/lib/csu/amd64/crt1.c:(.text+0x1b4): undefined reference to
`__fini_array_start'
Quoted 1 line
/usr/bin/ld:tools/mkenvimage: hidden symbol `__preinit_array_start'
isn't defined
Quoted 2 lines
Which seems to be about missing sections. The (default) ld on FreeBSD
branched of from an old version [1],
Quoted 4 lines
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
Quoted 1 line
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.
Quoted 1 line
- 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.
Quoted 1 line
- 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.
Quoted 1 line
- 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.
tools/imagetool.ldsdiff --git
Quoted 10 lines
With kind regards,
Jeroen[1]
ld --version
GNU ld 2.17.50 [FreeBSD] 2007-07-03[2]
tools/imagetool.ldsdiff --git renamed from tools/imagetool.lds +0
-0
a/tools/imagetool.lds b/tools/imagetool.lds
Quoted 23 lines
index 7e92b4a..b18eadb 100644
tools/imagetool.lds +12
-1@@ -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; */
Hi Simon,
I introduced that file to use the linker list with the image types. Like you suggested long time ago.
Best regards,
2015-02-05 1:34 GMT-02:00 Simon Glass <[email protected]>:
Quoted 99 lines
Hi Jeroen,
tools/imagetool.ldsdiff --git
Quoted 66 lines · Jeroen Hofstee
Hello Guilherme / Simon,
It seems that commit
f86ed6a8d52c99bb2d17d3cac1647edca0c4399c, "tools: moved code common to all image tools to a separated module."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 definedWhich 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 inimagetool.lds
- what it the INSERT BEFORE .data supposed to do?
- and last but not least, how can we make this work in general
- and really last, how do I test if it works..With kind regards,
Jeroen[1]
ld --version
GNU ld 2.17.50 [FreeBSD] 2007-07-03[2]
tools/imagetool.ldsdiff --git renamed from tools/imagetool.lds +0
-0Where is this file?
Quoted 14 lines
a/tools/imagetool.ldsb/tools/imagetool.lds
index 7e92b4a..b18eadb 100644tools/imagetool.lds +5
-0@@ -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 = .);tools/imagetool.lds SECTIONS · line 35
Quoted 10 lines
tools/imagetool.lds +7
-1+ 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; */Regards,
Simon
Signature · 4 lines
Guilherme Maciel Ferreira Mobile Brazil: +55 48 9917 3969 Site: http://guilhermemacielferreira.com/ Skype: guilherme.maciel.ferreira
Hello Guilherme,
Thanks for commenting on this,
Quoted 7 lines · Guilherme Maciel Ferreira
Hi Jeroen,
My apologies, I didn't test the tools on BSD. The answers are inline.
Best regards,
Guilherme
Quoted 9 lines
Am 04.02.2015 19:37 schrieb "Jeroen Hofstee" <[email protected]>:
Quoted 4 lines
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 bylinker_listsfeature". Because that commit introduced the linker script to imagetools.
Likely, since some patches depend on each other I was unable to revert a single commit.
Anyway as far as I am concerned there are two separate
build targets, the bare u-boot having an (almost) naked compiler, beside stdarg and stdbool? without any other host includes or objects (well with CONFIG_USE_PRIVATE_LIBGCC=y). U-boot provides linker scripts for them, and we have fine grained control over them and an excuse to throw any trick at them if it makes things faster / smaller etc. It is still nice if this
compiles anywhere though..
On the other hand there are "tools" for the host / target userland, which should build against the host / targets "std*". Those things should be buildable
on any decent host / target and be straightforward (and _not_ define KERNEL etc, since it are userland tools). There is no linker for them afaik, so tweaking
them seems like a bad idea. Hence I am tempted to remove the use of linker generated lists from tools...
Quoted 6 lines
Quoted 1 line
- and really last, how do I test if it works..
There are two scripts to test the image tools,
test-imagetools.shandtest-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.
Quoted 6 lines
$ 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
Sandbox used to build on FreeBSD, but it is quite a mess at the moment. But a I said, I think the best solution for tools is not to use linker generated
list in the first place for tools.
Regards,
Jeroen
Hi Jeroen,
Quoted 61 lines · Jeroen Hofstee
Hello Guilherme,
Thanks for commenting on this,
Quoted 10 lines · Guilherme Maciel Ferreira
Hi Jeroen,
My apologies, I didn't test the tools on BSD. The answers are inline.
Best regards,
GuilhermeAm 04.02.2015 19:37 schrieb "Jeroen Hofstee" <[email protected]>:
Quoted 1 line
Quoted 9 lines
Quoted 4 lines
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 bylinker_listsfeature". Because that commit introduced the linker script to imagetools.Likely, since some patches depend on each other I was unable to revert a single commit.
Anyway as far as I am concerned there are two separate
build targets, the bare u-boot having an (almost) naked compiler, beside stdarg and stdbool? without any other host includes or objects (well withCONFIG_USE_PRIVATE_LIBGCC=y). U-boot provides linker scripts for them, and we have fine grained control over them and an excuse to throw any trick at them if it makes things faster / smaller etc. It is still nice if this
compiles anywhere though..On the other hand there are "tools" for the host / target userland, which should build against the host / targets "std*". Those things should be buildable
on any decent host / target and be straightforward (and _not_ define KERNEL etc, since it are userland tools). There is no linker for them afaik, so tweaking
them seems like a bad idea. Hence I am tempted to remove the use of linker generated lists from tools...Quoted 7 lines
Quoted 1 line
- and really last, how do I test if it works..
There are two scripts to test the image tools,
test-imagetools.shandtest-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.Quoted 6 lines
$ 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
Quoted 4 lines
Sandbox used to build on FreeBSD, but it is quite a mess at the moment. But a I said, I think the best solution for tools is not to use linker generated
list in the first place for tools.
Sandbox uses driver model so has the same problem. How can we solve this?
Why is the FreeBSD toolchain so different? Does it not have the concept of link scripts?
Regards,
Simon
Hello Simon, +Andreas,
Quoted 57 lines · Simon Glass
Hi Jeroen,
Quoted 54 lines · Jeroen Hofstee
Hello Guilherme,
Thanks for commenting on this,
Quoted 7 lines · Guilherme Maciel Ferreira
Hi Jeroen,
My apologies, I didn't test the tools on BSD. The answers are inline.
Best regards,
GuilhermeQuoted 9 lines
Am 04.02.2015 19:37 schrieb "Jeroen Hofstee"<[email protected]>:
Quoted 4 lines
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 bylinker_listsfeature". Because that commit introduced the linker script to imagetools.Likely, since some patches depend on each other I was unable to revert a single commit.
Anyway as far as I am concerned there are two separate
build targets, the bare u-boot having an (almost) naked compiler, beside stdarg and stdbool? without any other host includes or objects (well withCONFIG_USE_PRIVATE_LIBGCC=y). U-boot provides linker scripts for them, and we have fine grained control over them and an excuse to throw any trick at them if it makes things faster / smaller etc. It is still nice if this
compiles anywhere though..On the other hand there are "tools" for the host / target userland, which should build against the host / targets "std*". Those things should be buildable
on any decent host / target and be straightforward (and _not_ define KERNEL etc, since it are userland tools). There is no linker for them afaik, so tweaking
them seems like a bad idea. Hence I am tempted to remove the use of linker generated lists from tools...Quoted 12 lines
Quoted 1 line
- and really last, how do I test if it works..
There are two scripts to test the image tools,
test-imagetools.shandtest-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
Quoted 8 lines
Quoted 4 lines
Sandbox used to build on FreeBSD, but it is quite a mess at the moment. But a I said, I think the best solution for tools is not to use linker generated
list in the first place for tools.Sandbox uses driver model so has the same problem. How can we solve this?
Why is the FreeBSD toolchain so different? Does it not have the concept of link scripts?
First of all, the biggest problem for sandbox at the moment are header files.
For a "normal" cross target this works fine since the target uses u-boot headers
(linux/*) and the tools the (std*). For sandbox we end up with both of them included at the same time at the moment, leading to redefinitions of uint64_t, time_t, ptrdiff_t, fd_set etc. I will have to look in more details
if this is fixable. It is a different problem then the link error since it already
errors before attempting to link.
Regarding the linking problem, there is nothing special about FreeBSD ld, it just is based on a version which has no idea what INSERT BEFORE .data means.
there are several option I guess (not tested):
1) include a complete linker script so INSERT BEFORE .data is not needed
2) teach FreeBSD ld what INSERT BEFORE .data is supposed to mean
3) don't use linker magic in tools (and use a linux box for sandbox, at least for now)
1) sounds like a bad idea, the target/host might be any arch e.g.
2) won't magically fix problems as well, even if FreeBSD trunk can be teached to understand
this, things will still be broken on releases. And u-boot tools work on more host systems,
Andreas, can you check if Darwin is still able to compile tools from u-boot master?
3) the option I would be tempted to choose, just don't do linker magic for tools. This would
make sure at least mkimage etc can be build everywhere. sandbox won't build, but as said
it is already broken because of other issues. (and I doubt there is even an single user around
besides me to even try to build sandbox on FreeBSD).
So as far as I am concerned we go for option 3.
Regards,
Jeroen
Hi,
Quoted 30 lines · Jeroen Hofstee
Hello Simon, +Andreas,
Quoted 16 lines · Simon Glass
Hi Jeroen,
Quoted 13 lines · Jeroen Hofstee
Hello Guilherme,
Thanks for commenting on this,
Quoted 8 lines · Guilherme Maciel Ferreira
Hi Jeroen,
My apologies, I didn't test the tools on BSD. The answers are inline.
Best regards,
GuilhermeAm 04.02.2015 19:37 schrieb "Jeroen Hofstee"<[email protected]>:
Regarding the linking problem, there is nothing special about FreeBSD ld, it just is based on a version which has no idea what INSERT BEFORE .data means.
there are several option I guess (not tested):
1) include a complete linker script so INSERT BEFORE .data is not needed
2) teach FreeBSD ld what INSERT BEFORE .data is supposed to mean
3) don't use linker magic in tools (and use a linux box for sandbox, at least for now)
Quoted 7 lines
1) sounds like a bad idea, the target/host might be any arch e.g.
2) won't magically fix problems as well, even if FreeBSD trunk can be teached to understand
this, things will still be broken on releases. And u-boot tools work on more host systems,
Andreas, can you check if Darwin is still able to compile tools from u-boot master?
unfortunately it does not.
---8<---
andreas at imac % git describe
v2015.04-rc1-4-g7f641d5
andreas at imac % PATH=/Volumes/crosstool-ng/arm-unknown-linux-uclibcgnueabi/bin:$PATH make CROSS_COMPILE=arm-unknown-linux-uclibcgnueabi- V=1
...
gcc -T ./tools/imagetool.lds -o tools/envcrc tools/envcrc.otools/lib/crc32.o tools/common/env_embedded.o tools/lib/sha1.o
ld: unknown option: -T
collect2: error: ld returned 1 exit status
make[1]: *** [tools/envcrc] Error 1
make: *** [tools] Error 2
andreas@imac % gcc --version
gcc (MacPorts gcc49 4.9.2_1) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --->8---
Quoted 9 lines
3) the option I would be tempted to choose, just don't do linker magic for tools. This would
make sure at least mkimage etc can be build everywhere. sandbox won't build, but as said
it is already broken because of other issues. (and I doubt there is even an single user around
besides me to even try to build sandbox on FreeBSD).So as far as I am concerned we go for option 3.
+1
Dynamic list-sections is in general a good thing. But beside the linker problem here we will get another problem on darwin hosts when we want to read the sections. I added a patch to linux kernel to get around [1].
So I have another option here:
4) setup the lists sections in code, add the magic handling for Mach-O binaries and remove the linker foo.
Best regards
Andreas Bie?mann
Hi,
Quoted 75 lines · Andreas Bie?mann
Hi,
Quoted 30 lines · Jeroen Hofstee
Hello Simon, +Andreas,
Quoted 16 lines · Simon Glass
Hi Jeroen,
Quoted 13 lines · Jeroen Hofstee
Hello Guilherme,
Thanks for commenting on this,
Quoted 8 lines · Guilherme Maciel Ferreira
Hi Jeroen,
My apologies, I didn't test the tools on BSD. The answers are inline.
Best regards,
GuilhermeAm 04.02.2015 19:37 schrieb "Jeroen Hofstee"<[email protected]>:
Regarding the linking problem, there is nothing special about FreeBSD ld, it just is based on a version which has no idea what INSERT BEFORE .data means.
there are several option I guess (not tested):
1) include a complete linker script so INSERT BEFORE .data is not needed
2) teach FreeBSD ld what INSERT BEFORE .data is supposed to mean
3) don't use linker magic in tools (and use a linux box for sandbox, at least for now)Quoted 7 lines
1) sounds like a bad idea, the target/host might be any arch e.g.
2) won't magically fix problems as well, even if FreeBSD trunk can be teached to understand
this, things will still be broken on releases. And u-boot tools work on more host systems,
Andreas, can you check if Darwin is still able to compile tools from u-boot master?unfortunately it does not.
---8<---
andreas at imac % git describe
v2015.04-rc1-4-g7f641d5
andreas at imac % PATH=/Volumes/crosstool-ng/arm-unknown-linux-uclibcgnueabi/bin:$PATH make CROSS_COMPILE=arm-unknown-linux-uclibcgnueabi- V=1
...
gcc -T./tools/imagetool.lds-otools/envcrctools/envcrc.otools/lib/crc32.otools/common/env_embedded.otools/lib/sha1.o
ld: unknown option: -T
collect2: error: ld returned 1 exit status
make[1]: *** [tools/envcrc] Error 1
make: *** [tools] Error 2
andreas at imac % gcc --version
gcc (MacPorts gcc49 4.9.2_1) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --->8---Quoted 9 lines
3) the option I would be tempted to choose, just don't do linker magic for tools. This would
make sure at least mkimage etc can be build everywhere. sandbox won't build, but as said
it is already broken because of other issues. (and I doubt there is even an single user around
besides me to even try to build sandbox on FreeBSD).So as far as I am concerned we go for option 3.
+1
Quoted 8 lines
Dynamic list-sections is in general a good thing. But beside the linker problem here we will get another problem on darwin hosts when we want to read the sections. I added a patch to linux kernel to get around [1].
So I have another option here:
4) setup the lists sections in code, add the magic handling for Mach-O binaries and remove the linker foo.
The lower-common-denominator approach is a bit frustrating. How does FreeBSD compile U-Boot? What are you actually using that system for if it cannot build U-Boot?
Re 1) I found an open in ld to produce the standard link script. I actually used that before I found INSERT BEFORE.
Before giving up I think it would be worth exploring 1). It should then be possible to make sandbox work also.
Finally, please point me to how I can install FreeBSD in viritualbox or similar. I'm interested in that...
Regards,
Simon
Hi Simon,
Quoted 80 lines · Simon Glass
Hi,
Quoted 76 lines · Andreas Bie?mann
Hi,
Quoted 29 lines · Jeroen Hofstee
Hello Simon, +Andreas,
Quoted 16 lines · Simon Glass
Hi Jeroen,
Quoted 13 lines · Jeroen Hofstee
Hello Guilherme,
Thanks for commenting on this,
Quoted 8 lines · Guilherme Maciel Ferreira
Hi Jeroen,
My apologies, I didn't test the tools on BSD. The answers are inline.
Best regards,
GuilhermeAm 04.02.2015 19:37 schrieb "Jeroen Hofstee"<[email protected]>:
Regarding the linking problem, there is nothing special about FreeBSD ld, it just is based on a version which has no idea what INSERT BEFORE .data means.
there are several option I guess (not tested):
1) include a complete linker script so INSERT BEFORE .data is not needed
2) teach FreeBSD ld what INSERT BEFORE .data is supposed to mean
3) don't use linker magic in tools (and use a linux box for sandbox, at least for now)Quoted 7 lines
1) sounds like a bad idea, the target/host might be any arch e.g.
2) won't magically fix problems as well, even if FreeBSD trunk can be teached to understand
this, things will still be broken on releases. And u-boot tools work on more host systems,
Andreas, can you check if Darwin is still able to compile tools from u-boot master?unfortunately it does not.
---8<---
andreas at imac % git describe
v2015.04-rc1-4-g7f641d5
andreas at imac % PATH=/Volumes/crosstool-ng/arm-unknown-linux-uclibcgnueabi/bin:$PATH make CROSS_COMPILE=arm-unknown-linux-uclibcgnueabi- V=1
...
gcc -T./tools/imagetool.lds-otools/envcrctools/envcrc.otools/lib/crc32.otools/common/env_embedded.otools/lib/sha1.o
ld: unknown option: -T
collect2: error: ld returned 1 exit status
make[1]: *** [tools/envcrc] Error 1
make: *** [tools] Error 2
andreas at imac % gcc --version
gcc (MacPorts gcc49 4.9.2_1) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --->8---Quoted 9 lines
3) the option I would be tempted to choose, just don't do linker magic for tools. This would
make sure at least mkimage etc can be build everywhere. sandbox won't build, but as said
it is already broken because of other issues. (and I doubt there is even an single user around
besides me to even try to build sandbox on FreeBSD).So as far as I am concerned we go for option 3.
+1
Dynamic list-sections is in general a good thing. But beside the linker problem here we will get another problem on darwin hosts when we want to read the sections. I added a patch to linux kernel to get around [1].
Quoted 6 lines
Quoted 4 lines
So I have another option here:
4) setup the lists sections in code, add the magic handling for Mach-O binaries and remove the linker foo.
The lower-common-denominator approach is a bit frustrating. How does FreeBSD compile U-Boot?
I guess I am missing the point here. U-boot v2015.01 builds fine on FreeBSD and as far as I know on a mac as well. It is v2015.04-rc1 which no longer builds mkimage on FreeBSD and Darwin.
Quoted 2 lines
What are you actually using that system for if
it cannot build U-Boot?
I am missing the point, u-boot and its tools build fine until v2015.04-rc1 on FreeBSD and a mac. And this is easily fixed by not using linker magic for tools. (and yes sandbox likely fails to build, but I don't care that much)
Quoted 5 lines
Re 1) I found an open in ld to produce the standard link script. I actually used that before I found INSERT BEFORE.
Before giving up I think it would be worth exploring 1). It should then be possible to make sandbox work also.
I am not giving up, I think it is sane if a tool which adds a header and a checksum does not use linker magic. Sandbox biggest problem is not the linking, but the fact that linux headers and std* are included, it is a different topic.
Quoted 2 lines
Finally, please point me to how I can install FreeBSD in viritualbox or similar. I'm interested in that...
Just download an install image and start it in virtualbox, see 1. You might need to change the motherboard type.
doc/README.clang explains how to use the host compiler to cross build u-boot (for some boards). You can install a gcc cross compiler as well.
Hi Jeroen,
Quoted 109 lines · Jeroen Hofstee
Hi Simon,
Quoted 93 lines · Simon Glass
Hi,
Quoted 88 lines · Andreas Bie?mann
Hi,
Quoted 36 lines · Jeroen Hofstee
Hello Simon, +Andreas,
Quoted 20 lines · Simon Glass
Hi Jeroen,
Quoted 15 lines · Jeroen Hofstee
Hello Guilherme,
Thanks for commenting on this,
Quoted 9 lines · Guilherme Maciel Ferreira
Hi Jeroen,
My apologies, I didn't test the tools on BSD. The answers are inline.
Best regards,
GuilhermeAm 04.02.2015 19:37 schrieb "Jeroen Hofstee"<[email protected]>:
Regarding the linking problem, there is nothing special about FreeBSD ld,
it just is based on a version which has no idea what INSERT BEFORE .data means.there are several option I guess (not tested):
1) include a complete linker script so INSERT BEFORE .data is not needed
2) teach FreeBSD ld what INSERT BEFORE .data is supposed to mean
3) don't use linker magic in tools (and use a linux box for sandbox, at least for now)Quoted 7 lines
1) sounds like a bad idea, the target/host might be any arch e.g.
2) won't magically fix problems as well, even if FreeBSD trunk can be teached to understand
this, things will still be broken on releases. And u-boot tools work on more host systems,
Andreas, can you check if Darwin is still able to compile tools from u-boot master?unfortunately it does not.
---8<---
andreas at imac % git describe
v2015.04-rc1-4-g7f641d5
andreas at imac % PATH=/Volumes/crosstool-ng/arm-unknown-linux-uclibcgnueabi/bin:$PATH make CROSS_COMPILE=arm-unknown-linux-uclibcgnueabi- V=1
...
gcc -T./tools/imagetool.lds-otools/envcrctools/envcrc.otools/lib/crc32.otools/common/env_embedded.otools/lib/sha1.o
ld: unknown option: -T
collect2: error: ld returned 1 exit status
make[1]: *** [tools/envcrc] Error 1
make: *** [tools] Error 2
andreas at imac % gcc --version
gcc (MacPorts gcc49 4.9.2_1) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--->8---Quoted 9 lines
3) the option I would be tempted to choose, just don't do linker magic for tools. This would
make sure at least mkimage etc can be build everywhere. sandbox won't build, but as said
it is already broken because of other issues. (and I doubt there is even an single user around
besides me to even try to build sandbox on FreeBSD).So as far as I am concerned we go for option 3.
+1
Dynamic list-sections is in general a good thing. But beside the linker problem here we will get another problem on darwin hosts when we want to read the sections. I added a patch to linux kernel to get around [1].
Quoted 7 lines
Quoted 4 lines
So I have another option here:
4) setup the lists sections in code, add the magic handling for Mach-O binaries and remove the linker foo.
The lower-common-denominator approach is a bit frustrating. How does FreeBSD compile U-Boot?
I guess I am missing the point here. U-boot v2015.01 builds fine on FreeBSD and as far as I know on a mac as well. It is v2015.04-rc1 which no longer builds mkimage on FreeBSD and Darwin.
Quoted 8 lines
Quoted 2 lines
What are you actually using that system for if
it cannot build U-Boot?I am missing the point, u-boot and its tools build fine until v2015.04-rc1 on FreeBSD and a mac. And this is easily fixed by not using linker magic for tools. (and yes sandbox likely fails to build, but I don't care that much)
How do you build U-Boot for any of the boards supported? What I mean is that if you can't handle linker scripts in FreeBSD how do you build anything beyond the 'tools' build?
The docs for 'ld' seem to indicate that if the -T option is not used the file is treated as a link script addendum rather than replacing it entirely. Is that what we want?
Quoted 4 lines
Quoted 4 lines
Re 1) I found an open in ld to produce the standard link script. I actually used that before I found INSERT BEFORE.
Quoted 8 lines
Quoted 2 lines
Before giving up I think it would be worth exploring 1). It should then be possible to make sandbox work also.
I am not giving up, I think it is sane if a tool which adds a header and a checksum does not use linker magic. Sandbox biggest problem is not the linking, but the fact that linux headers and std* are included, it is a different topic.
This should be easy to fix in os.c since all the inclusions are isolated to there. I'd been keen to see a patch for that. Also if you want LCD support, sdl.c.
Quoted 4 lines
Quoted 2 lines
Finally, please point me to how I can install FreeBSD in viritualbox or similar. I'm interested in that...
Quoted 8 lines
Just download an install image and start it in virtualbox, see 1. You might need to change the motherboard type.
doc/README.clang explains how to use the host compiler to cross build u-boot (for some boards). You can install a gcc cross compiler as well.
I tried this out and I have a prompt but I'm not sure how to install git or anything else 'pkg install git' tells me there are no packages available to install matching 'git'. pkg_add seems to be missing. I am none the wiser after some web searching.
Regards,
Simon
Hi Simon,
Quoted 15 lines · Simon Glass
Quoted 14 lines · Jeroen Hofstee
Quoted 13 lines · Simon Glass
Quoted 10 lines · Andreas Bie?mann
On 06.02.15 20:56, Jeroen Hofstee wrote:
Dynamic list-sections is in general a good thing. But beside the linker problem here we will get another problem on darwin hosts when we want to read the sections. I added a patch to linux kernel to get around [1].
So I have another option here:
4) setup the lists sections in code, add the magic handling for Mach-O binaries and remove the linker foo.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
The lower-common-denominator approach is a bit frustrating. How does FreeBSD compile U-Boot?
I guess I am missing the point here. U-boot v2015.01 builds fine on FreeBSD and as far as I know on a mac as well. It is v2015.04-rc1 which no longer builds mkimage on FreeBSD and Darwin.
Exactly that is the point. Before it worked to build the host tools on some exotic hosts. The introduced linker generated lists breaks this.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
What are you actually using that system for if
it cannot build U-Boot?I am missing the point, u-boot and its tools build fine until v2015.04-rc1 on FreeBSD and a mac. And this is easily fixed by not using linker magic for tools. (and yes sandbox likely fails to build, but I don't care that much)
How do you build U-Boot for any of the boards supported? What I mean is that if you can't handle linker scripts in FreeBSD how do you build anything beyond the 'tools' build?
to build U-Boot for any board we use a cross toolchain, to build the host tools we use the host compiler. In most cases the cross toolchain is gnu/linux which comes with a linker as we know in linux. But some host systems toolchain differ. *BSD with ELF as binary format is not really a problem here, cause the binary format is comparable. It requires just some tweaks for the used host-tools (e.g. host linker) and it will work. Unfortunately Darwin uses Mach-O as binary format which has some more restrictions. Especially it does not work with sections the same way as ELF does. Therefore I posted the patch for scripts/mod/file2alias.c in linux kernel to handle these. In days gone by we used to support windows as host too, at least with mingw which tries to clone a unix environment on windows. But the binary format on Windows is still PE (AFAIK) ... I wonder if the MS linker can generate those lists.
Please do not use the linker to generate those lists. Maybe we should use the kernel approach and build the lists inside the code.
Best regards
Andreas Bie?mann
Hi Andreas,
Quoted 41 lines · Andreas Bie?mann
Hi Simon,
Quoted 15 lines · Simon Glass
Quoted 14 lines · Jeroen Hofstee
Quoted 13 lines · Simon Glass
Quoted 10 lines · Andreas Bie?mann
On 06.02.15 20:56, Jeroen Hofstee wrote:
Dynamic list-sections is in general a good thing. But beside the linker problem here we will get another problem on darwin hosts when we want to read the sections. I added a patch to linux kernel to get around [1].
So I have another option here:
4) setup the lists sections in code, add the magic handling for Mach-O binaries and remove the linker foo.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
The lower-common-denominator approach is a bit frustrating. How does FreeBSD compile U-Boot?
I guess I am missing the point here. U-boot v2015.01 builds fine on FreeBSD and as far as I know on a mac as well. It is v2015.04-rc1 which no longer builds mkimage on FreeBSD and Darwin.
Exactly that is the point. Before it worked to build the host tools on some exotic hosts. The introduced linker generated lists breaks this.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
What are you actually using that system for if
it cannot build U-Boot?I am missing the point, u-boot and its tools build fine until v2015.04-rc1 on FreeBSD and a mac. And this is easily fixed by not using linker magic for tools. (and yes sandbox likely fails to build, but I don't care that much)
How do you build U-Boot for any of the boards supported? What I mean is that if you can't handle linker scripts in FreeBSD how do you build anything beyond the 'tools' build?
Quoted 14 lines
to build U-Boot for any board we use a cross toolchain, to build the host tools we use the host compiler. In most cases the cross toolchain is gnu/linux which comes with a linker as we know in linux. But some host systems toolchain differ. *BSD with ELF as binary format is not really a problem here, cause the binary format is comparable. It requires just some tweaks for the used host-tools (e.g. host linker) and it will work. Unfortunately Darwin uses Mach-O as binary format which has some more restrictions. Especially it does not work with sections the same way as ELF does. Therefore I posted the patch for
scripts/mod/file2alias.cin linux kernel to handle these. In days gone by we used to support windows as host too, at least with mingw which tries to clone a unix environment on windows. But the binary format on Windows is still PE (AFAIK) ... I wonder if the MS linker can generate those lists.
OK I see, so the GNU cross compilers are used on BSD, but the GNU x86 compiler is not used for host compiling.
Quoted 3 lines
Please do not use the linker to generate those lists. Maybe we should use the kernel approach and build the lists inside the code.
Can you point me to that please? I'm not familiar with it. The kernel uses all sorts of crazy link scripts - I wonder how FreeBSD deals with that? I suppose you can't compile Linux on FreeBSD natively?
Regards,
Simon
Hi Simon,
Quoted 56 lines · Simon Glass
Quoted 39 lines · Andreas Bie?mann
Quoted 15 lines · Simon Glass
Quoted 14 lines · Jeroen Hofstee
Quoted 13 lines · Simon Glass
Quoted 10 lines · Andreas Bie?mann
On 06.02.15 20:56, Jeroen Hofstee wrote:
Dynamic list-sections is in general a good thing. But beside the linker problem here we will get another problem on darwin hosts when we want to read the sections. I added a patch to linux kernel to get around [1].
So I have another option here:
4) setup the lists sections in code, add the magic handling for Mach-O binaries and remove the linker foo.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
The lower-common-denominator approach is a bit frustrating. How does FreeBSD compile U-Boot?
I guess I am missing the point here. U-boot v2015.01 builds fine on FreeBSD and as far as I know on a mac as well. It is v2015.04-rc1 which no longer builds mkimage on FreeBSD and Darwin.
Exactly that is the point. Before it worked to build the host tools on some exotic hosts. The introduced linker generated lists breaks this.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
What are you actually using that system for if
it cannot build U-Boot?I am missing the point, u-boot and its tools build fine until v2015.04-rc1 on FreeBSD and a mac. And this is easily fixed by not using linker magic for tools. (and yes sandbox likely fails to build, but I don't care that much)
How do you build U-Boot for any of the boards supported? What I mean is that if you can't handle linker scripts in FreeBSD how do you build anything beyond the 'tools' build?
Quoted 14 lines
to build U-Boot for any board we use a cross toolchain, to build the host tools we use the host compiler. In most cases the cross toolchain is gnu/linux which comes with a linker as we know in linux. But some host systems toolchain differ. *BSD with ELF as binary format is not really a problem here, cause the binary format is comparable. It requires just some tweaks for the used host-tools (e.g. host linker) and it will work. Unfortunately Darwin uses Mach-O as binary format which has some more restrictions. Especially it does not work with sections the same way as ELF does. Therefore I posted the patch for
scripts/mod/file2alias.cin linux kernel to handle these. In days gone by we used to support windows as host too, at least with mingw which tries to clone a unix environment on windows. But the binary format on Windows is still PE (AFAIK) ... I wonder if the MS linker can generate those lists.
Quoted 8 lines
OK I see, so the GNU cross compilers are used on BSD, but the GNU x86 compiler is not used for host compiling.
Quoted 3 lines
Please do not use the linker to generate those lists. Maybe we should use the kernel approach and build the lists inside the code.
Can you point me to that please?
I added correct section handling for Mach-O binary format to the file2alias.c [1] when they introduced dynamic sections (ADD_TO_DEVTABLE() macro in that file) which broke compilation on darwin.
Quoted 1 line
I'm not familiar with it.
Me too, I just fixed the build when it was broken.
Quoted 3 lines
The kernel
uses all sorts of crazy link scripts - I wonder how FreeBSD deals with that?
AFAIK there is no link script for any host tool. They use it heavily for the kernel. But again, this is compiled and linked with the gnu linux cross tool chain.
Quoted 1 line
I suppose you can't compile Linux on FreeBSD natively?
This will not work.
Best regards
Andreas Bie?mann
Hi Andreas,
Quoted 68 lines · Andreas Bie?mann
Hi Simon,
Quoted 56 lines · Simon Glass
Quoted 39 lines · Andreas Bie?mann
Quoted 15 lines · Simon Glass
Quoted 14 lines · Jeroen Hofstee
Quoted 13 lines · Simon Glass
Quoted 10 lines · Andreas Bie?mann
On 06.02.15 20:56, Jeroen Hofstee wrote:
Dynamic list-sections is in general a good thing. But beside the linker problem here we will get another problem on darwin hosts when we want to read the sections. I added a patch to linux kernel to get around [1].
So I have another option here:
4) setup the lists sections in code, add the magic handling for Mach-O binaries and remove the linker foo.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
The lower-common-denominator approach is a bit frustrating. How does FreeBSD compile U-Boot?
I guess I am missing the point here. U-boot v2015.01 builds fine on FreeBSD and as far as I know on a mac as well. It is v2015.04-rc1 which no longer builds mkimage on FreeBSD and Darwin.
Exactly that is the point. Before it worked to build the host tools on some exotic hosts. The introduced linker generated lists breaks this.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
What are you actually using that system for if
it cannot build U-Boot?I am missing the point, u-boot and its tools build fine until v2015.04-rc1 on FreeBSD and a mac. And this is easily fixed by not using linker magic for tools. (and yes sandbox likely fails to build, but I don't care that much)
How do you build U-Boot for any of the boards supported? What I mean is that if you can't handle linker scripts in FreeBSD how do you build anything beyond the 'tools' build?
Quoted 14 lines
to build U-Boot for any board we use a cross toolchain, to build the host tools we use the host compiler. In most cases the cross toolchain is gnu/linux which comes with a linker as we know in linux. But some host systems toolchain differ. *BSD with ELF as binary format is not really a problem here, cause the binary format is comparable. It requires just some tweaks for the used host-tools (e.g. host linker) and it will work. Unfortunately Darwin uses Mach-O as binary format which has some more restrictions. Especially it does not work with sections the same way as ELF does. Therefore I posted the patch for
scripts/mod/file2alias.cin linux kernel to handle these. In days gone by we used to support windows as host too, at least with mingw which tries to clone a unix environment on windows. But the binary format on Windows is still PE (AFAIK) ... I wonder if the MS linker can generate those lists.Quoted 8 lines
OK I see, so the GNU cross compilers are used on BSD, but the GNU x86 compiler is not used for host compiling.
Quoted 3 lines
Please do not use the linker to generate those lists. Maybe we should use the kernel approach and build the lists inside the code.
Can you point me to that please?
Quoted 7 lines
I added correct section handling for Mach-O binary format to the
file2alias.c[1] when they introduced dynamic sections (ADD_TO_DEVTABLE()macro in that file) which broke compilation on darwin.Quoted 1 line
I'm not familiar with it.
Me too, I just fixed the build when it was broken.
So are you saying that we need to write a tool which converts the ELF sections in the u-boot ELF into C code which then gets compiled and put into a final u-boot ELF? And if we did that then sandbox would work?
BTW I never did have any success getting a dev environment up on a Mac. It took hours to download and install things and then I can't remember what went wrong but it was awful. This was about 2 years ago
- maybe things have got easier? I'm happy to fiddle with this sort of thing but my pain tolerance isn't what it was/
Quoted 8 lines
Quoted 4 lines
The kernel
uses all sorts of crazy link scripts - I wonder how FreeBSD deals with that?AFAIK there is no link script for any host tool. They use it heavily for the kernel. But again, this is compiled and linked with the gnu linux cross tool chain.
Ah OK. And compiling U-Boot sandbox with a gnu linux cross tool chain (with x86 target) on BSD is not an option? I suppose it would not run.
Quoted 11 lines
Quoted 2 lines
I suppose you can't compile Linux on FreeBSD natively?
This will not work.
Best regards
Andreas Bie?mann
Regards,
Simon
Hello Simon,
Quoted 10 lines · Simon Glass
Quoted 6 lines · Jeroen Hofstee
I am missing the point, u-boot and its tools build fine until v2015.04-rc1 on FreeBSD and a mac. And this is easily fixed by not using linker magic for tools. (and yes sandbox likely fails to build, but I don't care that much)
How do you build U-Boot for any of the boards supported? What I mean is that if you can't handle linker scripts in FreeBSD how do you build anything beyond the 'tools' build?
FreeBSD host ld can handle linker scripts fine, it is INSERT BEFORE .data; which is not supported. Boards don't use the host linker script, but one for the target, which comes from ports and hence is not that old e.g.
arm-gnueabi-freebsd-ld --version
GNU ld (GNU Binutils) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
Besides that, boards don't use INSERT before .data, since they have a complete
linker script.
Quoted 3 lines
The docs for 'ld' seem to indicate that if the -T option is not used the file is treated as a link script addendum rather than replacing it entirely. Is that what we want?
FreeBSD ld has this option, it does not work on a MAC/Darwin though according to Andreas his post. The problem on FreeBSD is the INSERT before .data
inside the "addendum" aka tools/imagetool.lds
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Finally, please point me to how I can install FreeBSD in viritualbox or similar. I'm interested in that...
Just download an install image and start it in virtualbox, see 1. You might need to change the motherboard type.
doc/README.clang explains how to use the host compiler to cross build u-boot (for some boards). You can install a gcc cross compiler as well.
Quoted 6 lines
Quoted 2 lines
I tried this out and I have a prompt but I'm not sure how to install git or anything else 'pkg install git' tells me there are no packages available to install matching 'git'.
pkg_addseems to be missing. I am none the wiser after some web searching.
pkg replaced the pkg_add / pkg_info and friends. So it is fine that they are not there. The weird thing is I just booted 10.1 in virtualbox to reproduce
this but works fine (just defaults everywhere), I roughly did [1]. Obviously you
need root credentials to install packages, but I doubt you forgot that.
If this still fails, you can always build it from source, but needs a bit of patience.
Somthing like this should always work:
portsnap fetch
portsnap extract
cd /usr/ports/devel/git
make config-recursive
make
make install
Let me know if you still have issues.
Regards,
Jeroen
[1] (as root)
pkg install nano git
git clone git://git.denx.de/u-boot.git
git checkout v2015.01 -b b2015.01
cd u-boot
pkg install arm-gnueabi-binutils gmake
gmake CC="clang -target arm-freebsd-eabi -no-integrated-as -mllvm -arm-use-movt=0" rpi_defconfig
gmake CROSS_COMPILE=arm-gnueabi-freebsd- CC="clang -target arm-freebsd-eabi -no-integrated-as -mllvm -arm-use-movt=0 -B/usr/local/bin/arm-gnueabi-freebsd-" CONFIG_USE_PRIVATE_LIBGCC=y
Hi Jeroen,
Quoted 41 lines · Jeroen Hofstee
Hello Simon,
Quoted 11 lines · Simon Glass
Quoted 8 lines · Jeroen Hofstee
I am missing the point, u-boot and its tools build fine until v2015.04-rc1
on FreeBSD and a mac. And this is easily fixed by not using linker magic for tools. (and yes sandbox likely fails to build, but I don't care that much)Quoted 3 lines
How do you build U-Boot for any of the boards supported? What I mean is that if you can't handle linker scripts in FreeBSD how do you build anything beyond the 'tools' build?
FreeBSD host ld can handle linker scripts fine, it is INSERT BEFORE .data; which is not supported. Boards don't use the host linker script, but one for the target, which comes from ports and hence is not that old e.g.
arm-gnueabi-freebsd-ld --version
GNU ld (GNU Binutils) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.Besides that, boards don't use INSERT before .data, since they have a complete
linker script.Quoted 3 lines
The docs for 'ld' seem to indicate that if the -T option is not used the file is treated as a link script addendum rather than replacing it entirely. Is that what we want?
Quoted 4 lines
FreeBSD ld has this option, it does not work on a MAC/Darwin though according to Andreas his post. The problem on FreeBSD is the INSERT before .data
inside the "addendum" akatools/imagetool.lds
Do you need INSERT BEFORE or would it just work to specify the .lds fragment on the ld command line without -T?
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Finally, please point me to how I can install FreeBSD in viritualbox or similar. I'm interested in that...
Just download an install image and start it in virtualbox, see 1. You might need to change the motherboard type.
doc/README.clang explains how to use the host compiler to cross build u-boot (for some boards). You can install a gcc cross compiler as well.
Quoted 6 lines
Quoted 2 lines
I tried this out and I have a prompt but I'm not sure how to install git or anything else 'pkg install git' tells me there are no packages available to install matching 'git'.
pkg_addseems to be missing. I am none the wiser after some web searching.
Quoted 6 lines
pkg replaced the
pkg_add/pkg_infoand friends. So it is fine that they are not there. The weird thing is I just booted 10.1 in virtualbox to reproduce
this but works fine (just defaults everywhere), I roughly did [1]. Obviously you
need root credentials to install packages, but I doubt you forgot that.
I may as well press on and figure this out.
I tried again and this time it is fine. Last time I tried to install system documentation and source code, and it tried to install the package manager but maybe it failed and then put things in a broken state. Thanks for the help.
Quoted 31 lines
If this still fails, you can always build it from source, but needs a bit of patience.
Somthing like this should always work:portsnap fetch
portsnap extractcd
/usr/ports/devel/git
make config-recursive
make
make installLet me know if you still have issues.
Regards,
Jeroen[1] (as root)
pkg install nano git
git clonegit://git.denx.de/u-boot.git
git checkout v2015.01 -b b2015.01
cd u-boot
pkg install arm-gnueabi-binutils gmakegmake CC="clang -target arm-freebsd-eabi -no-integrated-as -mllvm -arm-use-movt=0"
rpi_defconfig
gmake CROSS_COMPILE=arm-gnueabi-freebsd- CC="clang -target arm-freebsd-eabi
Review
Quoted 2 lines
(quoted diff) +0
-2-no-integrated-as -mllvm -arm-use-movt=0 -B/usr/local/bin/arm-gnueabi-freebsd-" CONFIG_USE_PRIVATE_LIBGCC=y
Is this for using an ARM cross-compiler? What should I do for building the tools? I keep seeing 'gcc not found'.
Regards,
Simon
RFC PATCH 1/1 tools/imagetool: remove linker generated list
In reply to Andreas BießmannCommit a93648d197df48fa46dd55f925ff70468bd81c71 introduced linker generated lists for imagetool which is part of mkimage. It is a nice feature to remove the annoying register function calls, but is not portable. Unfortunately some host compilers do not support this type of linker scripts. Therefore this commit broke this host-tool for theem, namely FreeBSD and Darwin (OS/X).
This commit tries to fix this. We won't go back to the register functions but we also can not use the linker script. So use another approach copied from linux kernel scripts/mod/file2alias.c.
---
tools/Makefile | 2 -- tools/imagetool.c | 34 +++++++++++++++---------------- tools/imagetool.h | 56 +++++++++++++++++++++++++++++++++++++++++---------- tools/imagetool.lds | 24 ---------------------- 4 files changed, 61 insertions(+), 55 deletions(-) delete mode 100644 tools/imagetool.lds
tools/Makefile +0 -2
@@ -124,8 +124,6 @@ HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage) HOSTLOADLIBES_fit_info := $(HOSTLOADLIBES_mkimage) HOSTLOADLIBES_fit_check_sign := $(HOSTLOADLIBES_mkimage) -HOSTLDFLAGS += -T $(srctree)/tools/imagetool.lds - hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl HOSTCFLAGS_mkexynosspl.o := -pedantic
tools/imagetool.c +16 -18
@@ -12,16 +12,15 @@struct image_type_params *imagetool_get_type (int type) { -struct image_type_params *curr; -struct image_type_params *start =ll_entry_start ( - struct image_type_params, image_type); -struct image_type_params *end =ll_entry_end ( - struct image_type_params, image_type); +struct image_type_params **curr; +INIT_SECTION (image_type); +struct image_type_params **start = __start_image_type; +struct image_type_params **end = __stop_image_type;for (curr = start; curr != end; curr++) { -if (curr->check_image_type) { -if (!curr->check_image_type (type)) -return curr; +if ((*curr)->check_image_type) { +if (!(*curr)->check_image_type (type)) +return *curr; } }return NULL ;
@@ -34,16 +33,15 @@ int imagetool_verify_print_header( struct image_tool_params *params) {int retval =-1 ; -struct image_type_params *curr; +struct image_type_params **curr; +INIT_SECTION (image_type); -struct image_type_params *start =ll_entry_start ( - struct image_type_params, image_type); -struct image_type_params *end =ll_entry_end ( - struct image_type_params, image_type); +struct image_type_params **start = __start_image_type; +struct image_type_params **end = __stop_image_type;for (curr = start; curr != end; curr++) { -if (curr->verify_header) { - retval = curr->verify_header ((unsigned char *)ptr, +if ((*curr)->verify_header) { + retval = (*curr)->verify_header ((unsigned char *)ptr, sbuf->st_size, params);if (retval ==0 ) {
@@ -51,12 +49,12 @@ int imagetool_verify_print_header(* Print the image information if verify is * successful */ -if (curr->print_header) { - curr->print_header (ptr); +if ((*curr)->print_header) { + (*curr)->print_header (ptr); }else {fprintf (stderr,"%s: print_header undefined for %s\n" , - params->cmdname, curr->name); + params->cmdname, (*curr)->name); }break ; }
tools/imagetool.h +45 -11
79 lines not on this page · raw message
tools/imagetool.lds deleted +0 -24
@@ -1,24 +0,0 @@ -/* - * Copyright (c) 2011-2012 The Chromium OS Authors. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -SECTIONS -{ - - . = ALIGN(4); - .u_boot_list : { - KEEP(*(SORT(.u_boot_list*))); - } - - __u_boot_sandbox_option_start = .; - _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) } - __u_boot_sandbox_option_end = .; - - __bss_start = .; -} - -INSERT BEFORE .data;
Signature · 1 line
1.7.10.4
RFC PATCH 1/1 tools/imagetool: remove linker generated list
Thanks,
Quoted 6 lines · Andreas Bie?mann
Commit
a93648d197df48fa46dd55f925ff70468bd81c71introduced linker generated lists for imagetool which is part of mkimage. It is a nice feature to remove the annoying register function calls, but is not portable. Unfortunately some host compilers do not support this type of linker scripts. Therefore this commit broke this host-tool for theem, namely FreeBSD and Darwin (OS/X).
Quoted 7 lines
This commit tries to fix this. We won't go back to the register functions but we also can not use the linker script. So use another approach copied from linux kernel
scripts/mod/file2alias.c.Signed-off-by Andreas Bie?mann <[email protected]>Cc Guilherme Maciel Ferreira <[email protected]>
I haven't looked into the details yet, but at least things build again on FreeBSD with this patch. And tools/mkimage at least displays a help :)
Thanks again, regards
Jeroen
RFC PATCH 1/1 tools/imagetool: remove linker generated list
In reply to Andreas BießmannHi,
The code looks fine, and it works on my Linux host.
Best regards,
2015-02-07 19:19 GMT-02:00 Andreas Bie?mann <[email protected]>:
Quoted 221 lines
Commit
a93648d197df48fa46dd55f925ff70468bd81c71introduced linker generated lists for imagetool which is part of mkimage. It is a nice feature to remove the annoying register function calls, but is not portable. Unfortunately some host compilers do not support this type of linker scripts. Therefore this commit broke this host-tool for theem, namely FreeBSD and Darwin (OS/X).This commit tries to fix this. We won't go back to the register functions but we also can not use the linker script. So use another approach copied from linux kernel
scripts/mod/file2alias.c.Signed-off-by Andreas Bie?mann <[email protected]>Cc Guilherme Maciel Ferreira <[email protected]>---
tools/Makefile | 2 -- tools/imagetool.c | 34 +++++++++++++++---------------- tools/imagetool.h | 56 +++++++++++++++++++++++++++++++++++++++++---------- tools/imagetool.lds | 24 ---------------------- 4 files changed, 61 insertions(+), 55 deletions(-) delete mode 100644 tools/imagetool.ldstools/Makefile +0
-2@@ -124,8 +124,6 @@ HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage) HOSTLOADLIBES_fit_info := $(HOSTLOADLIBES_mkimage) HOSTLOADLIBES_fit_check_sign := $(HOSTLOADLIBES_mkimage) -HOSTLDFLAGS += -T $(srctree)/tools/imagetool.lds - hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl HOSTCFLAGS_mkexynosspl.o := -pedantictools/imagetool.c +16
-18@@ -12,16 +12,15 @@struct image_type_params *imagetool_get_type (int type) { -struct image_type_params *curr; -struct image_type_params *start =ll_entry_start ( - struct image_type_params, image_type); -struct image_type_params *end =ll_entry_end ( - struct image_type_params, image_type); +struct image_type_params **curr; +INIT_SECTION (image_type); +struct image_type_params **start = __start_image_type; +struct image_type_params **end = __stop_image_type;for (curr = start; curr != end; curr++) { -if (curr->check_image_type) { -if (!curr->check_image_type (type)) -return curr; +if ((*curr)->check_image_type) { +if (!(*curr)->check_image_type (type)) +return *curr; } }return NULL ;@@ -34,16 +33,15 @@ int imagetool_verify_print_header( struct image_tool_params *params) {int retval =-1 ; -struct image_type_params *curr; +struct image_type_params **curr; +INIT_SECTION (image_type); -struct image_type_params *start =ll_entry_start ( - struct image_type_params, image_type); -struct image_type_params *end =ll_entry_end ( - struct image_type_params, image_type); +struct image_type_params **start = __start_image_type; +struct image_type_params **end = __stop_image_type;for (curr = start; curr != end; curr++) { -if (curr->verify_header) { - retval = curr->verify_header ((unsigned char *)ptr, +if ((*curr)->verify_header) { + retval = (*curr)->verify_header ((unsigned char *)ptr, sbuf->st_size, params);if (retval ==0 ) {@@ -51,12 +49,12 @@ int imagetool_verify_print_header(* Print the image information if verify is * successful */ -if (curr->print_header) { - curr->print_header (ptr); +if ((*curr)->print_header) { + (*curr)->print_header (ptr); }else {fprintf (stderr,"%s: print_header undefined for %s\n" , - params->cmdname, curr->name); + params->cmdname, (*curr)->name); }break ; }tools/imagetool.h +45
-11@@ -20,15 +20,6 @@#include <unistd.h> #include <u-boot/sha1.h> -/* define __KERNEL__ in order to get the definitions -* required by the linker list. This is probably not -* the best way to do this */ -#ifndef __KERNEL__ -#define __KERNEL__ -#include <linker_lists.h> -#undef __KERNEL__ -#endif /* __KERNEL__ */ -#include "fdt_host.h" #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))@@ -194,6 +185,46 @@ int imagetool_save_subimage(void pbl_load_uboot (int fd,struct image_tool_params *mparams); +#define ___cat (a, b) a ## b +#define __cat (a, b) ___cat(a, b) + +/* we need some special handling for this host tool running eventually on +* Darwin. The Mach-O section handling is a bit different than ELF section +* handling. The differnces in detail are: +* a) we have segments which have sections +* b) we need a API call to get the respective section symbols */ +#if defined(__MACH__) +#include <mach-o/getsect.h> + +#define INIT_SECTION (name) do { \ + unsigned long name ## _len; \ + char *__cat(pstart_, name) = getsectdata("__TEXT", \ + #name, &__cat(name, _len)); \ + char *__cat(pstop_, name) = __cat(pstart_, name) + \ + __cat(name, _len); \ + __cat(__start_, name) = (void *)__cat(pstart_, name); \ + __cat(__stop_, name) = (void *)__cat(pstop_, name); \ + } while (0) +#define SECTION (name) __attribute__((section("__TEXT, " #name))) + +struct image_type_params **__start_image_type, **__stop_image_type; +#else +#define INIT_SECTION (name)/* no-op for ELF */ +#define SECTION (name) __attribute__((section(#name))) + +/* We construct a table of pointers in an ELF section (pointers generally +* go unpadded by gcc). ld creates boundary syms for us. */ +extern struct image_type_params *__start_image_type[], *__stop_image_type[]; +#endif /* __MACH__ */ + +#if !defined(__used) +# if __GNUC__ ==3 && __GNUC_MINOR__ <3 +# define __used __attribute__((__unused__)) +# else +# define __used __attribute__((__used__)) +# endif +#endif + #define U_BOOT_IMAGE_TYPE( \ _id, \ _name, \@@ -208,7 +239,8 @@ void pbl_load_uboot(int fd, struct image_tool_params *mparams); _fflag_handle, \ _vrec_header \ ) \ -ll_entry_declare (struct image_type_params ,_id ,image_type ) = { \ +static struct image_type_params __cat (image_type_ ,_id ) = \ + { \ .name = _name, \ .header_size = _header_size, \ .hdr = _header, \@@ -220,6 +252,8 @@ void pbl_load_uboot(int fd, struct image_tool_params *mparams); .check_image_type = _check_image_type, \ .fflag_handle = _fflag_handle, \ .vrec_header = _vrec_header \ - } + }; \ +static struct image_type_params *SECTION (image_type ) __used \ + __cat(image_type_ptr_, _id) = &__cat(image_type_, _id)#endif /* _IMAGETOOL_H_ */ tools/imagetool.lds deleted +0
-25@@ -1,24 +0,0 @@ -/* - * Copyright (c) 2011-2012 The Chromium OS Authors. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -SECTIONS -{ - - . = ALIGN(4); - .u_boot_list : { - KEEP(*(SORT(.u_boot_list*))); - } - - __u_boot_sandbox_option_start = .; - _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) } - __u_boot_sandbox_option_end = .; - - __bss_start = .; -} - -INSERT BEFORE .data; --1.7.10.4
Signature · 4 lines
Guilherme Maciel Ferreira Mobile Brazil: +55 48 9917 3969 Site: http://guilhermemacielferreira.com/ Skype: guilherme.maciel.ferreira
Hello Simon,
Quoted 26 lines · Simon Glass
Quoted 26 lines
If this still fails, you can always build it from source, but needs a bit of patience.
Somthing like this should always work:portsnap fetch
portsnap extractcd
/usr/ports/devel/git
make config-recursive
make
make installLet me know if you still have issues.
Regards,
Jeroen[1] (as root)
pkg install nano git
git clonegit://git.denx.de/u-boot.git
git checkout v2015.01 -b b2015.01
cd u-boot
pkg install arm-gnueabi-binutils gmake
Quoted 8 lines
Review
Quoted 6 lines
gmake CC="clang -target arm-freebsd-eabi -no-integrated-as -mllvm -arm-use-movt=0"
rpi_defconfig
gmake CROSS_COMPILE=arm-gnueabi-freebsd- CC="clang -target arm-freebsd-eabi(quoted diff) +0
-2-no-integrated-as -mllvm -arm-use-movt=0 -B/usr/local/bin/arm-gnueabi-freebsd-" CONFIG_USE_PRIVATE_LIBGCC=yIs this for using an ARM cross-compiler? What should I do for building the tools? I keep seeing 'gcc not found'.
Yes it is for cross building. So the host clang / host ld do the native build, the host clang with some help from arm-gnueabi-freebsd-as and arm-gnueabi-freebsd-ld do the cross build.
If you only want to build tools for the host you need something like:
gmake CC=cc sandbox_config tools
Since CC is defined to $(CROSS_COMPILE)gcc it ends up being gcc when CROSS_COMPILE is not set, hence you get the 'gcc not found' errors.
Regards,
Jeroen
[U-Boot] sandbox on FreeBSD
In reply to Simon GlassHello Simon,
Quoted 9 lines · Simon Glass
Quoted 6 lines
I am not giving up, I think it is sane if a tool which adds a header and a checksum does not use linker magic. Sandbox biggest problem is not the linking, but the fact that linux headers and std* are included, it is a different topic.
This should be easy to fix in
os.csince all the inclusions are isolated to there. I'd been keen to see a patch for that. Also if you want LCD support,sdl.c.
I had a look at this and hacked my way through and linked it with a GNU ld (GNU Binutils) 2.25. So at least I have a binary, but unfortunately it doesn't work, and errors out with:
Fatal error 'Can't allocate initial thread' at line 350 in file /usr/src/lib/libthr/thread/thr_init.c (errno = 2)
The reason for this seems to be void _thread_init_hack(void) __attribute__ ((constructor));
which calls _libpthread_init -> _thr_alloc -> calloc and that calls the version
in u-boots version of dl-malloc which is not initialized yet.
Did you encounter such problems on linux as well? Or does libpthread simply not allocate memory before reaching main?
Regards,
Jeroen
ldd ../u-boot-build/u-boot
../u-boot-build/u-boot:
librt.so.1 => /usr/lib/librt.so.1 (0x800896000) libSDL-1.2.so.0 => /usr/local/lib/libSDL-1.2.so.0 (0x800a9c000) libthr.so.3 => /lib/libthr.so.3 (0x800d02000) libc.so.7 => /lib/libc.so.7 (0x800f27000)
libm.so.5 => /lib/libm.so.5 (0x8012d0000)
libvgl.so.6 => /usr/lib/libvgl.so.6 (0x8014f8000) libaa.so.1 => /usr/local/lib/libaa.so.1 (0x801701000) libusbhid.so.4 => /usr/lib/libusbhid.so.4 (0x801919000) libncurses.so.8 => /lib/libncurses.so.8 (0x801b1d000)
Hi Jeroen,
Quoted 47 lines · Jeroen Hofstee
Hello Simon,
Quoted 28 lines · Simon Glass
Quoted 28 lines
If this still fails, you can always build it from source, but needs a bit of
patience.
Somthing like this should always work:portsnap fetch
portsnap extractcd
/usr/ports/devel/git
make config-recursive
make
make installLet me know if you still have issues.
Regards,
Jeroen[1] (as root)
pkg install nano git
git clonegit://git.denx.de/u-boot.git
git checkout v2015.01 -b b2015.01
cd u-boot
pkg install arm-gnueabi-binutils gmakeQuoted 9 lines
Review
Quoted 7 lines
gmake CC="clang -target arm-freebsd-eabi -no-integrated-as -mllvm -arm-use-movt=0"
rpi_defconfig
gmake CROSS_COMPILE=arm-gnueabi-freebsd- CC="clang -target arm-freebsd-eabi(quoted diff) +0
-2-no-integrated-as -mllvm -arm-use-movt=0 -B/usr/local/bin/arm-gnueabi-freebsd-" CONFIG_USE_PRIVATE_LIBGCC=yIs this for using an ARM cross-compiler? What should I do for building the tools? I keep seeing 'gcc not found'.
Yes it is for cross building. So the host clang / host ld do the native build, the host clang with some help from arm-gnueabi-freebsd-as and arm-gnueabi-freebsd-ld do the cross build.
Quoted 6 lines
If you only want to build tools for the host you need something like:
gmake CC=cc
sandbox_configtoolsSince CC is defined to $(CROSS_COMPILE)gcc it ends up being gcc when
CROSS_COMPILEis not set, hence you get the 'gcc not found' errors.
Thanks for your help. I have a FreeBSD running now and can build the tools with your patch.
Regards,
Simon
RFC PATCH 1/1 tools/imagetool: remove linker generated list
In reply to Andreas BießmannHi Andreas,
Quoted 12 lines · Andreas Bie?mann
Commit
a93648d197df48fa46dd55f925ff70468bd81c71introduced linker generated lists for imagetool which is part of mkimage. It is a nice feature to remove the annoying register function calls, but is not portable. Unfortunately some host compilers do not support this type of linker scripts. Therefore this commit broke this host-tool for theem, namely FreeBSD and Darwin (OS/X).This commit tries to fix this. We won't go back to the register functions but we also can not use the linker script. So use another approach copied from linux kernel
scripts/mod/file2alias.c.Signed-off-by Andreas Bie?mann <[email protected]>Cc Guilherme Maciel Ferreira <[email protected]>
Quoted 8 lines
---
tools/Makefile | 2 -- tools/imagetool.c | 34 +++++++++++++++---------------- tools/imagetool.h | 56 +++++++++++++++++++++++++++++++++++++++++---------- tools/imagetool.lds | 24 ---------------------- 4 files changed, 61 insertions(+), 55 deletions(-) delete mode 100644 tools/imagetool.lds
I have a FreeBSD set up now thanks to Jeroen so have had a play with this.
Quoted 116 lines
tools/Makefile +0
-2@@ -124,8 +124,6 @@ HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage) HOSTLOADLIBES_fit_info := $(HOSTLOADLIBES_mkimage) HOSTLOADLIBES_fit_check_sign := $(HOSTLOADLIBES_mkimage) -HOSTLDFLAGS += -T $(srctree)/tools/imagetool.lds - hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl HOSTCFLAGS_mkexynosspl.o := -pedantictools/imagetool.c +16
-18@@ -12,16 +12,15 @@struct image_type_params *imagetool_get_type (int type) { -struct image_type_params *curr; -struct image_type_params *start =ll_entry_start ( - struct image_type_params, image_type); -struct image_type_params *end =ll_entry_end ( - struct image_type_params, image_type); +struct image_type_params **curr; +INIT_SECTION (image_type); +struct image_type_params **start = __start_image_type; +struct image_type_params **end = __stop_image_type;for (curr = start; curr != end; curr++) { -if (curr->check_image_type) { -if (!curr->check_image_type (type)) -return curr; +if ((*curr)->check_image_type) { +if (!(*curr)->check_image_type (type)) +return *curr; } }return NULL ;@@ -34,16 +33,15 @@ int imagetool_verify_print_header( struct image_tool_params *params) {int retval =-1 ; -struct image_type_params *curr; +struct image_type_params **curr; +INIT_SECTION (image_type); -struct image_type_params *start =ll_entry_start ( - struct image_type_params, image_type); -struct image_type_params *end =ll_entry_end ( - struct image_type_params, image_type); +struct image_type_params **start = __start_image_type; +struct image_type_params **end = __stop_image_type;for (curr = start; curr != end; curr++) { -if (curr->verify_header) { - retval = curr->verify_header ((unsigned char *)ptr, +if ((*curr)->verify_header) { + retval = (*curr)->verify_header ((unsigned char *)ptr, sbuf->st_size, params);if (retval ==0 ) {@@ -51,12 +49,12 @@ int imagetool_verify_print_header(* Print the image information if verify is * successful */ -if (curr->print_header) { - curr->print_header (ptr); +if ((*curr)->print_header) { + (*curr)->print_header (ptr); }else {fprintf (stderr,"%s: print_header undefined for %s\n" , - params->cmdname, curr->name); + params->cmdname, (*curr)->name); }break ; }tools/imagetool.h +11
-9@@ -20,15 +20,6 @@#include <unistd.h> #include <u-boot/sha1.h> -/* define __KERNEL__ in order to get the definitions -* required by the linker list. This is probably not -* the best way to do this */ -#ifndef __KERNEL__ -#define __KERNEL__ -#include <linker_lists.h> -#undef __KERNEL__ -#endif /* __KERNEL__ */ -#include "fdt_host.h" #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))@@ -194,6 +185,46 @@ int imagetool_save_subimage(void pbl_load_uboot (int fd,struct image_tool_params *mparams); +#define ___cat (a, b) a ## b +#define __cat (a, b) ___cat(a, b) + +/* we need some special handling for this host tool running eventually on +* Darwin. The Mach-O section handling is a bit different than ELF section +* handling. The differnces in detail are: +* a) we have segments which have sections +* b) we need a API call to get the respective section symbols */ +#if defined(__MACH__) +#include <mach-o/getsect.h> +
tools/imagetool.h int imagetool_save_subimage( · line 208
Quoted 10 lines
tools/imagetool.h +10
-0+#define INIT_SECTION (name) do { \ + unsigned long name ## _len; \ + char *__cat(pstart_, name) = getsectdata("__TEXT", \ + #name, &__cat(name, _len)); \ + char *__cat(pstop_, name) = __cat(pstart_, name) + \ + __cat(name, _len); \ + __cat(__start_, name) = (void *)__cat(pstart_, name); \ + __cat(__stop_, name) = (void *)__cat(pstop_, name); \ + } while (0) +#define SECTION (name) __attribute__((section("__TEXT, " #name)))
If I understand this correctly, in both cases we put things in a separate section so that all the pieces get collected together. The only difference seems to be the naming of the section - for MACH it has a __TEXT prefix. Is that right? If so, I wonder if this should go in linker_list.h?
For access to the data, here we are using a list of pointers to the struct rather than a list of struct. Why is that? I can't see that this is required by the MACH system.
If that is correct, then it should be easy to support linker_list on MACH, by:
- Adding a __TEXT prefix to all the section() bits in linker_lists.h
- Changing any access to the lists to use INIT_SECTION instead of going there directly
Then we should be able to support running sandbox.
Does that sound feasible?
Quoted 73 lines
tools/imagetool.h +24
-2+ +struct image_type_params **__start_image_type, **__stop_image_type; +#else +#define INIT_SECTION (name)/* no-op for ELF */ +#define SECTION (name) __attribute__((section(#name))) + +/* We construct a table of pointers in an ELF section (pointers generally +* go unpadded by gcc). ld creates boundary syms for us. */ +extern struct image_type_params *__start_image_type[], *__stop_image_type[]; +#endif /* __MACH__ */ + +#if !defined(__used) +# if __GNUC__ ==3 && __GNUC_MINOR__ <3 +# define __used __attribute__((__unused__)) +# else +# define __used __attribute__((__used__)) +# endif +#endif + #define U_BOOT_IMAGE_TYPE( \ _id, \ _name, \@@ -208,7 +239,8 @@ void pbl_load_uboot(int fd, struct image_tool_params *mparams); _fflag_handle, \ _vrec_header \ ) \ -ll_entry_declare (struct image_type_params ,_id ,image_type ) = { \ +static struct image_type_params __cat (image_type_ ,_id ) = \ + { \ .name = _name, \ .header_size = _header_size, \ .hdr = _header, \@@ -220,6 +252,8 @@ void pbl_load_uboot(int fd, struct image_tool_params *mparams); .check_image_type = _check_image_type, \ .fflag_handle = _fflag_handle, \ .vrec_header = _vrec_header \ - } + }; \ +static struct image_type_params *SECTION (image_type ) __used \ + __cat(image_type_ptr_, _id) = &__cat(image_type_, _id)#endif /* _IMAGETOOL_H_ */ tools/imagetool.lds deleted +0
-25@@ -1,24 +0,0 @@ -/* - * Copyright (c) 2011-2012 The Chromium OS Authors. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -SECTIONS -{ - - . = ALIGN(4); - .u_boot_list : { - KEEP(*(SORT(.u_boot_list*))); - } - - __u_boot_sandbox_option_start = .; - _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) } - __u_boot_sandbox_option_end = .; - - __bss_start = .; -} - -INSERT BEFORE .data; --
Quoted 2 lines
1.7.10.4
Regards,
Simon
[U-Boot] sandbox on FreeBSD
In reply to Jeroen HofsteeHi Jeroen,
Quoted 31 lines · Jeroen Hofstee
Hello Simon,
Quoted 11 lines · Simon Glass
Quoted 7 lines
I am not giving up, I think it is sane if a tool which adds a header and a checksum does not use linker magic. Sandbox biggest problem is not the linking, but the fact that linux headers and std* are included, it is a different topic.
This should be easy to fix in
os.csince all the inclusions are isolated to there. I'd been keen to see a patch for that. Also if you want LCD support,sdl.c.I had a look at this and hacked my way through and linked it with a GNU ld (GNU Binutils) 2.25. So at least I have a binary, but unfortunately it doesn't work, and errors out with:
Fatal error 'Can't allocate initial thread' at line 350 in file
/usr/src/lib/libthr/thread/thr_init.c(errno = 2)The reason for this seems to be void
_thread_init_hack(void)__attribute__((constructor));
which calls_libpthread_init->_thr_alloc-> calloc and that calls the version
in u-boots version of dl-malloc which is not initialized yet.
Quoted 2 lines
Did you encounter such problems on linux as well? Or does libpthread simply not allocate memory before reaching main?
No I see no such problem but I can understand why it might happen.
There is a USE_DL_PREFIX in malloc.h which might fix the naming clash. U-Boot sandbox uses mmap() to allocate memory from the OS.
It may be worth sending a patch even if you are not quite there?
I suspect we can adjust the Makefile to use U-Boot's internal malloc() only for U-Boot and not for the libraries it uses. I've done that sort of thing before and remember it being a little painful.
Quoted 6 lines
Regards,
Jeroen
Quoted 12 lines
ldd ../u-boot-build/u-boot
../u-boot-build/u-boot:
librt.so.1 =>/usr/lib/librt.so.1(0x800896000) libSDL-1.2.so.0 =>/usr/local/lib/libSDL-1.2.so.0(0x800a9c000) libthr.so.3 =>/lib/libthr.so.3(0x800d02000) libc.so.7 =>/lib/libc.so.7(0x800f27000)
libm.so.5 =>/lib/libm.so.5(0x8012d0000)
libvgl.so.6 =>/usr/lib/libvgl.so.6(0x8014f8000) libaa.so.1 =>/usr/local/lib/libaa.so.1(0x801701000) libusbhid.so.4 =>/usr/lib/libusbhid.so.4(0x801919000) libncurses.so.8 =>/lib/libncurses.so.8(0x801b1d000)
Regards,
Simon