Commit 5cfcf7e0fdb265672dd8ee7d3e881190ed06ff98

Authored by Simon Glass
1 parent 00ae40b3ae

binman: Add tests binaries with binman symbols

For testing we need to build some ELF files containing binman symbols. Add
these to the Makefile and check in the binaries:

   u_boot_binman_syms - normal, valid ELF file
   u_boot_binman_syms_bad - missing the __image_copy_start symbol
   u_boot_binman_syms_size - has a binman symbol with an invalid size

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 9 changed files with 103 additions and 1 deletions Side-by-side Diff

tools/binman/test/Makefile
... ... @@ -10,8 +10,12 @@
10 10 CFLAGS := -march=i386 -m32 -nostdlib -I ../../../include
11 11  
12 12 LDS_UCODE := -T u_boot_ucode_ptr.lds
  13 +LDS_BINMAN := -T u_boot_binman_syms.lds
  14 +LDS_BINMAN_BAD := -T u_boot_binman_syms_bad.lds
13 15  
14   -TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data
  16 +TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data \
  17 + u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \
  18 + u_boot_binman_syms_size
15 19  
16 20 all: $(TARGETS)
17 21  
... ... @@ -23,6 +27,18 @@
23 27  
24 28 bss_data: CFLAGS += bss_data.lds
25 29 bss_data: bss_data.c
  30 +
  31 +u_boot_binman_syms.bin: u_boot_binman_syms
  32 + objcopy -O binary $< -R .note.gnu.build-id $@
  33 +
  34 +u_boot_binman_syms: CFLAGS += $(LDS_BINMAN)
  35 +u_boot_binman_syms: u_boot_binman_syms.c
  36 +
  37 +u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD)
  38 +u_boot_binman_syms_bad: u_boot_binman_syms_bad.c
  39 +
  40 +u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN)
  41 +u_boot_binman_syms_size: u_boot_binman_syms_size.c
26 42  
27 43 clean:
28 44 rm -f $(TARGETS)
tools/binman/test/u_boot_binman_syms
No preview for this file type
tools/binman/test/u_boot_binman_syms.c
  1 +/*
  2 + * Copyright (c) 2017 Google, Inc
  3 + *
  4 + * SPDX-License-Identifier: GPL-2.0+
  5 + *
  6 + * Simple program to create some binman symbols. This is used by binman tests.
  7 + */
  8 +
  9 +#define CONFIG_BINMAN
  10 +#include <binman_sym.h>
  11 +
  12 +binman_sym_declare(unsigned long, u_boot_spl, pos);
  13 +binman_sym_declare(unsigned long long, u_boot_spl2, pos);
  14 +binman_sym_declare(unsigned long, u_boot_any, pos);
tools/binman/test/u_boot_binman_syms.lds
  1 +/*
  2 + * Copyright (c) 2016 Google, Inc
  3 + *
  4 + * SPDX-License-Identifier: GPL-2.0+
  5 + */
  6 +
  7 +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
  8 +OUTPUT_ARCH(i386)
  9 +ENTRY(_start)
  10 +
  11 +SECTIONS
  12 +{
  13 + . = 0x00000000;
  14 + _start = .;
  15 +
  16 + . = ALIGN(4);
  17 + .text :
  18 + {
  19 + __image_copy_start = .;
  20 + *(.text*)
  21 + }
  22 +
  23 + . = ALIGN(4);
  24 + .binman_sym_table : {
  25 + __binman_sym_start = .;
  26 + KEEP(*(SORT(.binman_sym*)));
  27 + __binman_sym_end = .;
  28 + }
  29 +
  30 +}
tools/binman/test/u_boot_binman_syms_bad
No preview for this file type
tools/binman/test/u_boot_binman_syms_bad.c
  1 +u_boot_binman_syms.c
tools/binman/test/u_boot_binman_syms_bad.lds
  1 +/*
  2 + * Copyright (c) 2016 Google, Inc
  3 + *
  4 + * SPDX-License-Identifier: GPL-2.0+
  5 + */
  6 +
  7 +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
  8 +OUTPUT_ARCH(i386)
  9 +ENTRY(_start)
  10 +
  11 +SECTIONS
  12 +{
  13 + . = 0x00000000;
  14 + _start = .;
  15 +
  16 + . = ALIGN(4);
  17 + .text :
  18 + {
  19 + *(.text*)
  20 + }
  21 +
  22 + . = ALIGN(4);
  23 + .binman_sym_table : {
  24 + __binman_sym_start = .;
  25 + KEEP(*(SORT(.binman_sym*)));
  26 + __binman_sym_end = .;
  27 + }
  28 +
  29 +}
tools/binman/test/u_boot_binman_syms_size
No preview for this file type
tools/binman/test/u_boot_binman_syms_size.c
  1 +/*
  2 + * Copyright (c) 2017 Google, Inc
  3 + *
  4 + * SPDX-License-Identifier: GPL-2.0+
  5 + *
  6 + * Simple program to create some binman symbols. This is used by binman tests.
  7 + */
  8 +
  9 +#define CONFIG_BINMAN
  10 +#include <binman_sym.h>
  11 +
  12 +binman_sym_declare(char, u_boot_spl, pos);