Re: [U-Boot] [RFC PATCH] tools/imagetool: remove linker generated list

2015-02-10 Thread Simon Glass
Hi Andreas,

On 7 February 2015 at 14:19, Andreas Bießmann
 wrote:
> Commit 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.
>
> Signed-off-by: Andreas Bießmann 
> Cc: Guilherme Maciel Ferreira 
> ---
>
>  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.

>
> diff --git a/tools/Makefile b/tools/Makefile
> index 6e1ce79..ea76a3e 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -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
> diff --git a/tools/imagetool.c b/tools/imagetool.c
> index 148e466..8563032 100644
> --- a/tools/imagetool.c
> +++ b/tools/imagetool.c
> @@ -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;
> }
> diff --git a/tools/imagetool.h b/tools/imagetool.h
> index f35dec7..3e15b4e 100644
> --- a/tools/imagetool.h
> +++ b/tools/imagetool.h
> @@ -20,15 +20,6 @@
>  #include 
>  #include 
>
> -/* defin

Re: [U-Boot] [RFC PATCH] tools/imagetool: remove linker generated list

2015-02-08 Thread Guilherme Maciel Ferreira
Hi,

The code looks fine, and it works on my Linux host.

Best regards,

2015-02-07 19:19 GMT-02:00 Andreas Bießmann :
> Commit 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.
>
> Signed-off-by: Andreas Bießmann 
> Cc: Guilherme Maciel Ferreira 
> ---
>
>  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
>
> diff --git a/tools/Makefile b/tools/Makefile
> index 6e1ce79..ea76a3e 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -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
> diff --git a/tools/imagetool.c b/tools/imagetool.c
> index 148e466..8563032 100644
> --- a/tools/imagetool.c
> +++ b/tools/imagetool.c
> @@ -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;
> }
> diff --git a/tools/imagetool.h b/tools/imagetool.h
> index f35dec7..3e15b4e 100644
> --- a/tools/imagetool.h
> +++ b/tools/imagetool.h
> @@ -20,15 +20,6 @@
>  #include 
>  #include 
>
> -/* define __KERNEL__ in order to 

Re: [U-Boot] [RFC PATCH] tools/imagetool: remove linker generated list

2015-02-07 Thread Jeroen Hofstee

Thanks,

On 02/07/15 22:19, Andreas Bießmann wrote:

Commit 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.

Signed-off-by: Andreas Bießmann 
Cc: Guilherme Maciel Ferreira 



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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot