mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-26 06:30:39 +00:00
binman: Allow symbols to be resolved inside sections
At present we only support symbols inside binaries which are at the top level of an image. This restrictions seems unreasonable since more complex images may want to group binaries within different sections. Relax the restriction, adding a new _SetupTplElf() helper function. Also fix a typo in the comment for testTpl(). Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c9a0b27589
commit
2090f1e3d0
4 changed files with 67 additions and 10 deletions
|
@ -40,4 +40,4 @@ class Entry_u_boot_spl(Entry_blob):
|
|||
return 'spl/u-boot-spl.bin'
|
||||
|
||||
def WriteSymbols(self, section):
|
||||
elf.LookupAndWriteSymbols(self.elf_fname, self, section)
|
||||
elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage())
|
||||
|
|
|
@ -40,4 +40,4 @@ class Entry_u_boot_tpl(Entry_blob):
|
|||
return 'tpl/u-boot-tpl.bin'
|
||||
|
||||
def WriteSymbols(self, section):
|
||||
elf.LookupAndWriteSymbols(self.elf_fname, self, section)
|
||||
elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage())
|
||||
|
|
|
@ -40,7 +40,7 @@ import tout
|
|||
U_BOOT_DATA = b'1234'
|
||||
U_BOOT_IMG_DATA = b'img'
|
||||
U_BOOT_SPL_DATA = b'56780123456789abcde'
|
||||
U_BOOT_TPL_DATA = b'tpl'
|
||||
U_BOOT_TPL_DATA = b'tpl9876543210fedcb'
|
||||
BLOB_DATA = b'89'
|
||||
ME_DATA = b'0abcd'
|
||||
VGA_DATA = b'vga'
|
||||
|
@ -491,6 +491,16 @@ class TestFunctional(unittest.TestCase):
|
|||
TestFunctional._MakeInputFile('spl/u-boot-spl',
|
||||
tools.ReadFile(cls.ElfTestFile(src_fname)))
|
||||
|
||||
@classmethod
|
||||
def _SetupTplElf(cls, src_fname='bss_data'):
|
||||
"""Set up an ELF file with a '_dt_ucode_base_size' symbol
|
||||
|
||||
Args:
|
||||
Filename of ELF file to use as TPL
|
||||
"""
|
||||
TestFunctional._MakeInputFile('tpl/u-boot-tpl',
|
||||
tools.ReadFile(cls.ElfTestFile(src_fname)))
|
||||
|
||||
@classmethod
|
||||
def TestFile(cls, fname):
|
||||
return os.path.join(cls._binman_dir, 'test', fname)
|
||||
|
@ -1557,10 +1567,9 @@ class TestFunctional(unittest.TestCase):
|
|||
"'other'", str(e.exception))
|
||||
|
||||
def testTpl(self):
|
||||
"""Test that an image with TPL and ots device tree can be created"""
|
||||
"""Test that an image with TPL and its device tree can be created"""
|
||||
# ELF file with a '__bss_size' symbol
|
||||
with open(self.ElfTestFile('bss_data'), 'rb') as fd:
|
||||
TestFunctional._MakeInputFile('tpl/u-boot-tpl', fd.read())
|
||||
self._SetupTplElf()
|
||||
data = self._DoReadFile('078_u_boot_tpl.dts')
|
||||
self.assertEqual(U_BOOT_TPL_DATA + U_BOOT_TPL_DTB_DATA, data)
|
||||
|
||||
|
@ -1814,8 +1823,7 @@ class TestFunctional(unittest.TestCase):
|
|||
u-boot-tpl.dtb with the microcode removed
|
||||
the microcode
|
||||
"""
|
||||
TestFunctional._MakeInputFile('tpl/u-boot-tpl',
|
||||
tools.ReadFile(self.ElfTestFile('u_boot_ucode_ptr')))
|
||||
self._SetupTplElf('u_boot_ucode_ptr')
|
||||
first, pos_and_size = self._RunMicrocodeTest('093_x86_tpl_ucode.dts',
|
||||
U_BOOT_TPL_NODTB_DATA)
|
||||
self.assertEqual(b'tplnodtb with microc' + pos_and_size +
|
||||
|
@ -1869,8 +1877,7 @@ class TestFunctional(unittest.TestCase):
|
|||
def testElf(self):
|
||||
"""Basic test of ELF entries"""
|
||||
self._SetupSplElf()
|
||||
with open(self.ElfTestFile('bss_data'), 'rb') as fd:
|
||||
TestFunctional._MakeInputFile('tpl/u-boot-tpl', fd.read())
|
||||
self._SetupTplElf()
|
||||
with open(self.ElfTestFile('bss_data'), 'rb') as fd:
|
||||
TestFunctional._MakeInputFile('-boot', fd.read())
|
||||
data = self._DoReadFile('096_elf.dts')
|
||||
|
@ -2029,6 +2036,7 @@ class TestFunctional(unittest.TestCase):
|
|||
fname: Filename of input file to provide (fitimage.bin or ifwi.bin)
|
||||
"""
|
||||
self._SetupSplElf()
|
||||
self._SetupTplElf()
|
||||
|
||||
# Intel Integrated Firmware Image (IFWI) file
|
||||
with gzip.open(self.TestFile('%s.gz' % fname), 'rb') as fd:
|
||||
|
@ -3292,6 +3300,27 @@ class TestFunctional(unittest.TestCase):
|
|||
self.assertIn("'intel-fit-ptr' section must have an 'intel-fit' sibling",
|
||||
str(e.exception))
|
||||
|
||||
def testSymbolsTplSection(self):
|
||||
"""Test binman can assign symbols embedded in U-Boot TPL in a section"""
|
||||
self._SetupSplElf('u_boot_binman_syms')
|
||||
self._SetupTplElf('u_boot_binman_syms')
|
||||
data = self._DoReadFile('149_symbols_tpl.dts')
|
||||
sym_values = struct.pack('<LQL', 4, 0x18, 0x30)
|
||||
upto1 = 4 + len(U_BOOT_SPL_DATA)
|
||||
expected1 = tools.GetBytes(0xff, 4) + sym_values + U_BOOT_SPL_DATA[16:]
|
||||
self.assertEqual(expected1, data[:upto1])
|
||||
|
||||
upto2 = upto1 + 1 + len(U_BOOT_SPL_DATA)
|
||||
expected2 = tools.GetBytes(0xff, 1) + sym_values + U_BOOT_SPL_DATA[16:]
|
||||
self.assertEqual(expected2, data[upto1:upto2])
|
||||
|
||||
upto3 = 0x30 + len(U_BOOT_DATA)
|
||||
expected3 = tools.GetBytes(0xff, 5) + U_BOOT_DATA
|
||||
self.assertEqual(expected3, data[upto2:upto3])
|
||||
|
||||
expected4 = sym_values + U_BOOT_TPL_DATA[16:]
|
||||
self.assertEqual(expected4, data[upto3:])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
28
tools/binman/test/149_symbols_tpl.dts
Normal file
28
tools/binman/test/149_symbols_tpl.dts
Normal file
|
@ -0,0 +1,28 @@
|
|||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
binman {
|
||||
pad-byte = <0xff>;
|
||||
u-boot-spl {
|
||||
offset = <4>;
|
||||
};
|
||||
|
||||
u-boot-spl2 {
|
||||
offset = <0x18>;
|
||||
type = "u-boot-spl";
|
||||
};
|
||||
|
||||
u-boot {
|
||||
offset = <0x30>;
|
||||
};
|
||||
|
||||
section {
|
||||
u-boot-tpl {
|
||||
type = "u-boot-tpl";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
Loading…
Reference in a new issue