[U-Boot,16/34] binman: Use the Makefile for u_boot_binman_syms
diff mbox series

Message ID 20190824132315.53130-17-sjg@chromium.org
State New
Delegated to: Simon Glass
Headers show
Series
  • binman: Various improvements and tidy-ups
Related show

Commit Message

Simon Glass Aug. 24, 2019, 1:22 p.m. UTC
Remove this file from git and instead build it using the Makefile.

With this change a few things need to be adjusted:

1. The 'notes' section no-longer appears at the start of the ELF file
(before the code), so update testSymbols to adjust the offsets.

2. The dynamic linker is disabled to avoid errors like:

    "Not enough room for program headers, try linking with -N"

3. The interpreter note is moved to the end of the image, so that the
binman symbols appear first.

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

 tools/binman/elf_test.py                 |   9 +++++----
 tools/binman/ftest.py                    |   7 ++++---
 tools/binman/test/Makefile               |   5 +++--
 tools/binman/test/u_boot_binman_syms     | Bin 4924 -> 0 bytes
 tools/binman/test/u_boot_binman_syms.lds |   1 +
 5 files changed, 13 insertions(+), 9 deletions(-)
 delete mode 100755 tools/binman/test/u_boot_binman_syms

Patch
diff mbox series

diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
index c7f51bb86a..ff036cb655 100644
--- a/tools/binman/elf_test.py
+++ b/tools/binman/elf_test.py
@@ -70,7 +70,8 @@  def BuildElfTestFiles(target_dir):
         del os.environ['MAKEFLAGS']
     tools.Run('make', '-C', target_dir, '-f',
               os.path.join(testdir, 'Makefile'), 'SRC=%s/' % testdir,
-              'bss_data', 'u_boot_ucode_ptr', 'u_boot_no_ucode_ptr')
+              'bss_data', 'u_boot_ucode_ptr', 'u_boot_no_ucode_ptr',
+              'u_boot_binman_syms', 'u_boot_binman_syms.bin')
 
 
 class TestElf(unittest.TestCase):
@@ -118,7 +119,7 @@  class TestElf(unittest.TestCase):
         """Test a symbol which extends outside the entry area is detected"""
         entry = FakeEntry(10)
         section = FakeSection()
-        elf_fname = os.path.join(binman_dir, 'test', 'u_boot_binman_syms')
+        elf_fname = self.ElfTestFile('u_boot_binman_syms')
         with self.assertRaises(ValueError) as e:
             syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
         self.assertIn('entry_path has offset 4 (size 8) but the contents size '
@@ -158,7 +159,7 @@  class TestElf(unittest.TestCase):
         """
         entry = FakeEntry(20)
         section = FakeSection(sym_value=None)
-        elf_fname = os.path.join(binman_dir, 'test', 'u_boot_binman_syms')
+        elf_fname = self.ElfTestFile('u_boot_binman_syms')
         syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
         self.assertEqual(tools.GetBytes(255, 16) + tools.GetBytes(ord('a'), 4),
                                                                   entry.data)
@@ -169,7 +170,7 @@  class TestElf(unittest.TestCase):
             tout.Init(tout.DEBUG)
             entry = FakeEntry(20)
             section = FakeSection()
-            elf_fname = os.path.join(binman_dir, 'test', 'u_boot_binman_syms')
+            elf_fname = self.ElfTestFile('u_boot_binman_syms')
             with test_util.capture_sys_output() as (stdout, stderr):
                 syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
             self.assertTrue(len(stdout.getvalue()) > 0)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 30a8b0b14c..507c481881 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -489,7 +489,8 @@  class TestFunctional(unittest.TestCase):
             Filename of ELF file to use as SPL
         """
         # TODO(sjg@chromium.org): Drop this when all Elf files use ElfTestFile()
-        if src_fname in ['bss_data', 'u_boot_ucode_ptr', 'u_boot_no_ucode_ptr']:
+        if src_fname in ['bss_data', 'u_boot_ucode_ptr', 'u_boot_no_ucode_ptr',
+                         'u_boot_binman_syms']:
             fname = cls.ElfTestFile(src_fname)
         else:
             fname = cls.TestFile(src_fname)
@@ -1223,14 +1224,14 @@  class TestFunctional(unittest.TestCase):
 
     def testSymbols(self):
         """Test binman can assign symbols embedded in U-Boot"""
-        elf_fname = self.TestFile('u_boot_binman_syms')
+        elf_fname = self.ElfTestFile('u_boot_binman_syms')
         syms = elf.GetSymbols(elf_fname, ['binman', 'image'])
         addr = elf.GetSymbolAddress(elf_fname, '__image_copy_start')
         self.assertEqual(syms['_binman_u_boot_spl_prop_offset'].address, addr)
 
         self._SetupSplElf('u_boot_binman_syms')
         data = self._DoReadFile('053_symbols.dts')
-        sym_values = struct.pack('<LQL', 0x24 + 0, 0x24 + 24, 0x24 + 20)
+        sym_values = struct.pack('<LQL', 0, 24, 20)
         expected = (sym_values + U_BOOT_SPL_DATA[16:] +
                     tools.GetBytes(0xff, 1) + U_BOOT_DATA + sym_values +
                     U_BOOT_SPL_DATA[16:])
diff --git a/tools/binman/test/Makefile b/tools/binman/test/Makefile
index fd660eac6e..7af5459793 100644
--- a/tools/binman/test/Makefile
+++ b/tools/binman/test/Makefile
@@ -8,10 +8,11 @@ 
 #
 
 VPATH := $(SRC)
-CFLAGS := -march=i386 -m32 -nostdlib -I ../../../include
+CFLAGS := -march=i386 -m32 -nostdlib -I $(SRC)../../../include \
+	-Wl,--no-dynamic-linker
 
 LDS_UCODE := -T $(SRC)u_boot_ucode_ptr.lds
-LDS_BINMAN := -T u_boot_binman_syms.lds
+LDS_BINMAN := -T $(SRC)u_boot_binman_syms.lds
 LDS_BINMAN_BAD := -T u_boot_binman_syms_bad.lds
 
 TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data \
diff --git a/tools/binman/test/u_boot_binman_syms b/tools/binman/test/u_boot_binman_syms
deleted file mode 100755
index 126a1a623092cbe25f7a24118d26d4a0e8d0e0fc..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 4924
zcmeHLziZn-6h22z-3|pOlrCKi)!;&M$UzabQ)p;IAp|;jJ|tU74Au{<6U9ri2C`;r
zyJaf0e?uVuMfa|SOdZ?rvwV*2lu|O^gHP|?``*2iK55ZAeY5|zR;vkPE5Z>b@{x4c
zE5;WsFm2Hg^@?wr9YU~<c)%3$^{J<$xl=Gty#Jy5aCeOR=i1)kZNe&G6|f3e1*`&A
z0jq#jz$#!BunJfOtO8bn`zgTx@h5-->>YH4`}5c1&&ByC=kmIE-njg7@cOG<?!33V
z`>NIMMrEqY*0%Jew;7a^sB_W@r02_y_o5<NTV5yd0`KK=kLB1*9o#A5h?RvBXKpS*
zqAqTJKZS1t4}mq*2k_j_XJUK-Z>))_MHhhw82$s+oLkVEs6T@@=QIAe5MwG*swm5}
ziUw&Crm7exh3p9vPRSx4ZmE2f<tjToEMol^{$F&Mjw^bQgh#Q;vqC6y0uEGh+Fwi*
zIvn8;Rn_;he5|UJkf_&T1g}SxKQ^m0)3H2COBt1eVSjVb7xMO@6pDwjki9HP;#5<e
z|FdT(YXGx1hhdJ<lO3o#jUN<eO#J4^yQrI=`<S{NaIE7yqxmS>u9lN4Ibsc9FJs@4
ncxM85*3jr@_lETl{jT6ScUlE_F7M+JFyC(j{k|b*%=G&MuziL^

diff --git a/tools/binman/test/u_boot_binman_syms.lds b/tools/binman/test/u_boot_binman_syms.lds
index 29cf9d0e54..926df873cb 100644
--- a/tools/binman/test/u_boot_binman_syms.lds
+++ b/tools/binman/test/u_boot_binman_syms.lds
@@ -25,5 +25,6 @@  SECTIONS
 		KEEP(*(SORT(.binman_sym*)));
 		__binman_sym_end = .;
 	}
+	.interp : { *(.interp*) }
 
 }