blob: e3dee79d065b4501876f58355057f50701c702de [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glassb50e5612017-11-13 18:54:54 -07002# Copyright (c) 2017 Google, Inc
3# Written by Simon Glass <sjg@chromium.org>
4#
Simon Glassb50e5612017-11-13 18:54:54 -07005# Test for the elf module
6
7import os
Simon Glassf58558a2019-07-08 13:18:34 -06008import shutil
Simon Glass056f0ef2021-11-03 21:09:16 -06009import struct
Simon Glassb50e5612017-11-13 18:54:54 -070010import sys
Simon Glassf58558a2019-07-08 13:18:34 -060011import tempfile
Simon Glassb50e5612017-11-13 18:54:54 -070012import unittest
13
Simon Glass16287932020-04-17 18:09:03 -060014from binman import elf
Simon Glass4583c002023-02-23 18:18:04 -070015from u_boot_pylib import command
16from u_boot_pylib import test_util
17from u_boot_pylib import tools
18from u_boot_pylib import tout
Simon Glassb50e5612017-11-13 18:54:54 -070019
20binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
Simon Glass19790632017-11-13 18:55:01 -070021
Simon Glass19790632017-11-13 18:55:01 -070022
23class FakeEntry:
Simon Glassb2b0df82018-07-17 13:25:26 -060024 """A fake Entry object, usedfor testing
25
26 This supports an entry with a given size.
27 """
Simon Glass19790632017-11-13 18:55:01 -070028 def __init__(self, contents_size):
29 self.contents_size = contents_size
Simon Glassc1aa66e2022-01-29 14:14:04 -070030 self.data = tools.get_bytes(ord('a'), contents_size)
Simon Glass19790632017-11-13 18:55:01 -070031
32 def GetPath(self):
33 return 'entry_path'
34
Simon Glassb2b0df82018-07-17 13:25:26 -060035
Simon Glassf55382b2018-06-01 09:38:13 -060036class FakeSection:
Simon Glassb2b0df82018-07-17 13:25:26 -060037 """A fake Section object, used for testing
38
39 This has the minimum feature set needed to support testing elf functions.
40 A LookupSymbol() function is provided which returns a fake value for amu
41 symbol requested.
42 """
Simon Glass19790632017-11-13 18:55:01 -070043 def __init__(self, sym_value=1):
44 self.sym_value = sym_value
45
46 def GetPath(self):
Simon Glassf55382b2018-06-01 09:38:13 -060047 return 'section_path'
Simon Glass19790632017-11-13 18:55:01 -070048
Simon Glass870a9ea2021-01-06 21:35:15 -070049 def LookupImageSymbol(self, name, weak, msg, base_addr):
Simon Glassb2b0df82018-07-17 13:25:26 -060050 """Fake implementation which returns the same value for all symbols"""
Simon Glass19790632017-11-13 18:55:01 -070051 return self.sym_value
Simon Glassb50e5612017-11-13 18:54:54 -070052
Simon Glass870a9ea2021-01-06 21:35:15 -070053 def GetImage(self):
54 return self
Simon Glassb2b0df82018-07-17 13:25:26 -060055
Simon Glass53e22bf2019-08-24 07:22:53 -060056def BuildElfTestFiles(target_dir):
57 """Build ELF files used for testing in binman
58
Simon Glass4d38dd72022-02-08 11:49:55 -070059 This compiles and links the test files into the specified directory. It uses
60 the Makefile and source files in the binman test/ directory.
Simon Glass53e22bf2019-08-24 07:22:53 -060061
62 Args:
63 target_dir: Directory to put the files into
64 """
65 if not os.path.exists(target_dir):
66 os.mkdir(target_dir)
67 testdir = os.path.join(binman_dir, 'test')
68
69 # If binman is involved from the main U-Boot Makefile the -r and -R
70 # flags are set in MAKEFLAGS. This prevents this Makefile from working
71 # correctly. So drop any make flags here.
72 if 'MAKEFLAGS' in os.environ:
73 del os.environ['MAKEFLAGS']
Simon Glass2fb2cd72021-11-03 21:09:15 -060074 try:
Simon Glassc1aa66e2022-01-29 14:14:04 -070075 tools.run('make', '-C', target_dir, '-f',
Simon Glass2fb2cd72021-11-03 21:09:15 -060076 os.path.join(testdir, 'Makefile'), 'SRC=%s/' % testdir)
77 except ValueError as e:
78 # The test system seems to suppress this in a strange way
79 print(e)
Simon Glass53e22bf2019-08-24 07:22:53 -060080
81
Simon Glassb50e5612017-11-13 18:54:54 -070082class TestElf(unittest.TestCase):
Simon Glasse0e62752018-10-01 21:12:41 -060083 @classmethod
Simon Glassf514d8f2019-08-24 07:22:54 -060084 def setUpClass(cls):
85 cls._indir = tempfile.mkdtemp(prefix='elf.')
Simon Glassc1aa66e2022-01-29 14:14:04 -070086 tools.set_input_dirs(['.'])
Simon Glassf514d8f2019-08-24 07:22:54 -060087 BuildElfTestFiles(cls._indir)
88
89 @classmethod
90 def tearDownClass(cls):
91 if cls._indir:
92 shutil.rmtree(cls._indir)
93
94 @classmethod
95 def ElfTestFile(cls, fname):
96 return os.path.join(cls._indir, fname)
Simon Glasse0e62752018-10-01 21:12:41 -060097
Simon Glassb50e5612017-11-13 18:54:54 -070098 def testAllSymbols(self):
Simon Glassb2b0df82018-07-17 13:25:26 -060099 """Test that we can obtain a symbol from the ELF file"""
Simon Glassf514d8f2019-08-24 07:22:54 -0600100 fname = self.ElfTestFile('u_boot_ucode_ptr')
Simon Glassb50e5612017-11-13 18:54:54 -0700101 syms = elf.GetSymbols(fname, [])
Simon Glass1e18a692022-01-09 20:13:37 -0700102 self.assertIn('_dt_ucode_base_size', syms)
Simon Glassb50e5612017-11-13 18:54:54 -0700103
104 def testRegexSymbols(self):
Simon Glassb2b0df82018-07-17 13:25:26 -0600105 """Test that we can obtain from the ELF file by regular expression"""
Simon Glassf514d8f2019-08-24 07:22:54 -0600106 fname = self.ElfTestFile('u_boot_ucode_ptr')
Simon Glassb50e5612017-11-13 18:54:54 -0700107 syms = elf.GetSymbols(fname, ['ucode'])
Simon Glass1e18a692022-01-09 20:13:37 -0700108 self.assertIn('_dt_ucode_base_size', syms)
Simon Glassb50e5612017-11-13 18:54:54 -0700109 syms = elf.GetSymbols(fname, ['missing'])
Simon Glass1e18a692022-01-09 20:13:37 -0700110 self.assertNotIn('_dt_ucode_base_size', syms)
Simon Glassb50e5612017-11-13 18:54:54 -0700111 syms = elf.GetSymbols(fname, ['missing', 'ucode'])
Simon Glass1e18a692022-01-09 20:13:37 -0700112 self.assertIn('_dt_ucode_base_size', syms)
Simon Glassb50e5612017-11-13 18:54:54 -0700113
Simon Glass19790632017-11-13 18:55:01 -0700114 def testMissingFile(self):
Simon Glassb2b0df82018-07-17 13:25:26 -0600115 """Test that a missing file is detected"""
Simon Glass19790632017-11-13 18:55:01 -0700116 entry = FakeEntry(10)
Simon Glassf55382b2018-06-01 09:38:13 -0600117 section = FakeSection()
Simon Glass19790632017-11-13 18:55:01 -0700118 with self.assertRaises(ValueError) as e:
Simon Glass8d2ef3e2022-02-11 13:23:21 -0700119 elf.LookupAndWriteSymbols('missing-file', entry, section)
Simon Glass19790632017-11-13 18:55:01 -0700120 self.assertIn("Filename 'missing-file' not found in input path",
121 str(e.exception))
122
123 def testOutsideFile(self):
Simon Glassb2b0df82018-07-17 13:25:26 -0600124 """Test a symbol which extends outside the entry area is detected"""
Stefan Herbrechtsmeier6ac7a832022-08-19 16:25:18 +0200125 if not elf.ELF_TOOLS:
126 self.skipTest('Python elftools not available')
Simon Glass19790632017-11-13 18:55:01 -0700127 entry = FakeEntry(10)
Simon Glassf55382b2018-06-01 09:38:13 -0600128 section = FakeSection()
Simon Glass1542c8b2019-08-24 07:22:56 -0600129 elf_fname = self.ElfTestFile('u_boot_binman_syms')
Simon Glass19790632017-11-13 18:55:01 -0700130 with self.assertRaises(ValueError) as e:
Simon Glass8d2ef3e2022-02-11 13:23:21 -0700131 elf.LookupAndWriteSymbols(elf_fname, entry, section)
Alper Nebi Yasak367ecbf2022-06-18 15:13:11 +0300132 self.assertIn('entry_path has offset 8 (size 8) but the contents size '
Simon Glass19790632017-11-13 18:55:01 -0700133 'is a', str(e.exception))
134
135 def testMissingImageStart(self):
Simon Glassb2b0df82018-07-17 13:25:26 -0600136 """Test that we detect a missing __image_copy_start symbol
137
138 This is needed to mark the start of the image. Without it we cannot
139 locate the offset of a binman symbol within the image.
140 """
Simon Glass19790632017-11-13 18:55:01 -0700141 entry = FakeEntry(10)
Simon Glassf55382b2018-06-01 09:38:13 -0600142 section = FakeSection()
Simon Glass8dc60f92019-08-24 07:22:58 -0600143 elf_fname = self.ElfTestFile('u_boot_binman_syms_bad')
Simon Glass7a58a0f2023-07-18 07:23:56 -0600144 count = elf.LookupAndWriteSymbols(elf_fname, entry, section)
145 self.assertEqual(0, count)
Simon Glass19790632017-11-13 18:55:01 -0700146
147 def testBadSymbolSize(self):
Simon Glassb2b0df82018-07-17 13:25:26 -0600148 """Test that an attempt to use an 8-bit symbol are detected
149
150 Only 32 and 64 bits are supported, since we need to store an offset
151 into the image.
152 """
Stefan Herbrechtsmeier6ac7a832022-08-19 16:25:18 +0200153 if not elf.ELF_TOOLS:
154 self.skipTest('Python elftools not available')
Simon Glass19790632017-11-13 18:55:01 -0700155 entry = FakeEntry(10)
Simon Glassf55382b2018-06-01 09:38:13 -0600156 section = FakeSection()
Simon Glasse9d2ee32019-08-24 07:22:57 -0600157 elf_fname =self.ElfTestFile('u_boot_binman_syms_size')
Simon Glass19790632017-11-13 18:55:01 -0700158 with self.assertRaises(ValueError) as e:
Simon Glass8d2ef3e2022-02-11 13:23:21 -0700159 elf.LookupAndWriteSymbols(elf_fname, entry, section)
Simon Glass19790632017-11-13 18:55:01 -0700160 self.assertIn('has size 1: only 4 and 8 are supported',
161 str(e.exception))
162
163 def testNoValue(self):
Simon Glassb2b0df82018-07-17 13:25:26 -0600164 """Test the case where we have no value for the symbol
165
Simon Glass7a58a0f2023-07-18 07:23:56 -0600166 This should produce -1 values for all three symbols, taking up the
Simon Glassb2b0df82018-07-17 13:25:26 -0600167 first 16 bytes of the image.
168 """
Stefan Herbrechtsmeier6ac7a832022-08-19 16:25:18 +0200169 if not elf.ELF_TOOLS:
170 self.skipTest('Python elftools not available')
Alper Nebi Yasak367ecbf2022-06-18 15:13:11 +0300171 entry = FakeEntry(28)
Simon Glassf55382b2018-06-01 09:38:13 -0600172 section = FakeSection(sym_value=None)
Simon Glass1542c8b2019-08-24 07:22:56 -0600173 elf_fname = self.ElfTestFile('u_boot_binman_syms')
Simon Glass7a58a0f2023-07-18 07:23:56 -0600174 count = elf.LookupAndWriteSymbols(elf_fname, entry, section)
175 self.assertEqual(5, count)
Alper Nebi Yasak367ecbf2022-06-18 15:13:11 +0300176 expected = (struct.pack('<L', elf.BINMAN_SYM_MAGIC_VALUE) +
177 tools.get_bytes(255, 20) +
178 tools.get_bytes(ord('a'), 4))
179 self.assertEqual(expected, entry.data)
Simon Glass19790632017-11-13 18:55:01 -0700180
181 def testDebug(self):
Simon Glassb2b0df82018-07-17 13:25:26 -0600182 """Check that enabling debug in the elf module produced debug output"""
Stefan Herbrechtsmeier6ac7a832022-08-19 16:25:18 +0200183 if not elf.ELF_TOOLS:
184 self.skipTest('Python elftools not available')
Simon Glass9f297b02019-07-20 12:23:36 -0600185 try:
Simon Glassf3385a52022-01-29 14:14:15 -0700186 tout.init(tout.DEBUG)
Alper Nebi Yasak367ecbf2022-06-18 15:13:11 +0300187 entry = FakeEntry(24)
Simon Glass9f297b02019-07-20 12:23:36 -0600188 section = FakeSection()
Simon Glass1542c8b2019-08-24 07:22:56 -0600189 elf_fname = self.ElfTestFile('u_boot_binman_syms')
Simon Glass9f297b02019-07-20 12:23:36 -0600190 with test_util.capture_sys_output() as (stdout, stderr):
Simon Glass8d2ef3e2022-02-11 13:23:21 -0700191 elf.LookupAndWriteSymbols(elf_fname, entry, section)
Simon Glass9f297b02019-07-20 12:23:36 -0600192 self.assertTrue(len(stdout.getvalue()) > 0)
193 finally:
Simon Glassf3385a52022-01-29 14:14:15 -0700194 tout.init(tout.WARNING)
Simon Glass19790632017-11-13 18:55:01 -0700195
Simon Glassf58558a2019-07-08 13:18:34 -0600196 def testMakeElf(self):
197 """Test for the MakeElf function"""
198 outdir = tempfile.mkdtemp(prefix='elf.')
199 expected_text = b'1234'
200 expected_data = b'wxyz'
201 elf_fname = os.path.join(outdir, 'elf')
Simon Glass9d44a7e2019-08-24 07:22:45 -0600202 bin_fname = os.path.join(outdir, 'bin')
Simon Glassf58558a2019-07-08 13:18:34 -0600203
204 # Make an Elf file and then convert it to a fkat binary file. This
205 # should produce the original data.
206 elf.MakeElf(elf_fname, expected_text, expected_data)
Simon Glassc1aa66e2022-01-29 14:14:04 -0700207 objcopy, args = tools.get_target_compile_tool('objcopy')
Alper Nebi Yasak1e4687a2020-09-06 14:46:05 +0300208 args += ['-O', 'binary', elf_fname, bin_fname]
Simon Glassd9800692022-01-29 14:14:05 -0700209 stdout = command.output(objcopy, *args)
Simon Glassf58558a2019-07-08 13:18:34 -0600210 with open(bin_fname, 'rb') as fd:
211 data = fd.read()
212 self.assertEqual(expected_text + expected_data, data)
213 shutil.rmtree(outdir)
214
Simon Glassd8d40742019-07-08 13:18:35 -0600215 def testDecodeElf(self):
216 """Test for the MakeElf function"""
217 if not elf.ELF_TOOLS:
218 self.skipTest('Python elftools not available')
219 outdir = tempfile.mkdtemp(prefix='elf.')
220 expected_text = b'1234'
221 expected_data = b'wxyz'
222 elf_fname = os.path.join(outdir, 'elf')
223 elf.MakeElf(elf_fname, expected_text, expected_data)
Simon Glassc1aa66e2022-01-29 14:14:04 -0700224 data = tools.read_file(elf_fname)
Simon Glassd8d40742019-07-08 13:18:35 -0600225
226 load = 0xfef20000
227 entry = load + 2
228 expected = expected_text + expected_data
229 self.assertEqual(elf.ElfInfo(expected, load, entry, len(expected)),
230 elf.DecodeElf(data, 0))
231 self.assertEqual(elf.ElfInfo(b'\0\0' + expected[2:],
232 load, entry, len(expected)),
233 elf.DecodeElf(data, load + 2))
Simon Glassf514d8f2019-08-24 07:22:54 -0600234 shutil.rmtree(outdir)
Simon Glassd8d40742019-07-08 13:18:35 -0600235
Simon Glass056f0ef2021-11-03 21:09:16 -0600236 def testEmbedData(self):
237 """Test for the GetSymbolFileOffset() function"""
238 if not elf.ELF_TOOLS:
239 self.skipTest('Python elftools not available')
240
241 fname = self.ElfTestFile('embed_data')
242 offset = elf.GetSymbolFileOffset(fname, ['embed_start', 'embed_end'])
243 start = offset['embed_start'].offset
244 end = offset['embed_end'].offset
Simon Glassc1aa66e2022-01-29 14:14:04 -0700245 data = tools.read_file(fname)
Simon Glass056f0ef2021-11-03 21:09:16 -0600246 embed_data = data[start:end]
Simon Glass060a65e2023-01-23 11:29:41 -0700247 expect = struct.pack('<IIIII', 2, 3, 0x1234, 0x5678, 0)
Simon Glass056f0ef2021-11-03 21:09:16 -0600248 self.assertEqual(expect, embed_data)
249
250 def testEmbedFail(self):
251 """Test calling GetSymbolFileOffset() without elftools"""
252 try:
253 old_val = elf.ELF_TOOLS
254 elf.ELF_TOOLS = False
255 fname = self.ElfTestFile('embed_data')
256 with self.assertRaises(ValueError) as e:
257 elf.GetSymbolFileOffset(fname, ['embed_start', 'embed_end'])
Lukas Funke43176ed2023-07-18 13:53:09 +0200258 with self.assertRaises(ValueError) as e:
259 elf.DecodeElf(tools.read_file(fname), 0xdeadbeef)
260 with self.assertRaises(ValueError) as e:
261 elf.GetFileOffset(fname, 0xdeadbeef)
262 with self.assertRaises(ValueError) as e:
263 elf.GetSymbolFromAddress(fname, 0xdeadbeef)
264 with self.assertRaises(ValueError) as e:
265 entry = FakeEntry(10)
266 section = FakeSection()
267 elf.LookupAndWriteSymbols(fname, entry, section, True)
268
269 self.assertIn(
270 "Section 'section_path': entry 'entry_path': Cannot write symbols to an ELF file without Python elftools",
271 str(e.exception))
Simon Glass056f0ef2021-11-03 21:09:16 -0600272 finally:
273 elf.ELF_TOOLS = old_val
274
275 def testEmbedDataNoSym(self):
276 """Test for GetSymbolFileOffset() getting no symbols"""
277 if not elf.ELF_TOOLS:
278 self.skipTest('Python elftools not available')
279
280 fname = self.ElfTestFile('embed_data')
281 offset = elf.GetSymbolFileOffset(fname, ['missing_sym'])
282 self.assertEqual({}, offset)
283
Simon Glass17b4ffc2022-03-05 20:18:57 -0700284 def test_read_loadable_segments(self):
285 """Test for read_loadable_segments()"""
Simon Glass4d38dd72022-02-08 11:49:55 -0700286 if not elf.ELF_TOOLS:
287 self.skipTest('Python elftools not available')
288 fname = self.ElfTestFile('embed_data')
Simon Glass17b4ffc2022-03-05 20:18:57 -0700289 segments, entry = elf.read_loadable_segments(tools.read_file(fname))
Simon Glass4d38dd72022-02-08 11:49:55 -0700290
291 def test_read_segments_fail(self):
Simon Glass17b4ffc2022-03-05 20:18:57 -0700292 """Test for read_loadable_segments() without elftools"""
Simon Glass4d38dd72022-02-08 11:49:55 -0700293 try:
294 old_val = elf.ELF_TOOLS
295 elf.ELF_TOOLS = False
296 fname = self.ElfTestFile('embed_data')
297 with self.assertRaises(ValueError) as e:
Simon Glass17b4ffc2022-03-05 20:18:57 -0700298 elf.read_loadable_segments(tools.read_file(fname))
299 self.assertIn("Python: No module named 'elftools'",
Simon Glass4d38dd72022-02-08 11:49:55 -0700300 str(e.exception))
301 finally:
302 elf.ELF_TOOLS = old_val
303
304 def test_read_segments_bad_data(self):
Simon Glass17b4ffc2022-03-05 20:18:57 -0700305 """Test for read_loadable_segments() with an invalid ELF file"""
Stefan Herbrechtsmeier6ac7a832022-08-19 16:25:18 +0200306 if not elf.ELF_TOOLS:
307 self.skipTest('Python elftools not available')
Simon Glass4d38dd72022-02-08 11:49:55 -0700308 fname = self.ElfTestFile('embed_data')
309 with self.assertRaises(ValueError) as e:
Simon Glass17b4ffc2022-03-05 20:18:57 -0700310 elf.read_loadable_segments(tools.get_bytes(100, 100))
Simon Glass4d38dd72022-02-08 11:49:55 -0700311 self.assertIn('Magic number does not match', str(e.exception))
312
Simon Glass40def8a2022-03-18 19:19:49 -0600313 def test_get_file_offset(self):
314 """Test GetFileOffset() gives the correct file offset for a symbol"""
Stefan Herbrechtsmeier6ac7a832022-08-19 16:25:18 +0200315 if not elf.ELF_TOOLS:
316 self.skipTest('Python elftools not available')
Simon Glass40def8a2022-03-18 19:19:49 -0600317 fname = self.ElfTestFile('embed_data')
318 syms = elf.GetSymbols(fname, ['embed'])
319 addr = syms['embed'].address
320 offset = elf.GetFileOffset(fname, addr)
321 data = tools.read_file(fname)
322
323 # Just use the first 4 bytes and assume it is little endian
324 embed_data = data[offset:offset + 4]
325 embed_value = struct.unpack('<I', embed_data)[0]
326 self.assertEqual(0x1234, embed_value)
327
328 def test_get_file_offset_fail(self):
329 """Test calling GetFileOffset() without elftools"""
330 try:
331 old_val = elf.ELF_TOOLS
332 elf.ELF_TOOLS = False
333 fname = self.ElfTestFile('embed_data')
334 with self.assertRaises(ValueError) as e:
335 elf.GetFileOffset(fname, 0)
336 self.assertIn("Python: No module named 'elftools'",
337 str(e.exception))
338 finally:
339 elf.ELF_TOOLS = old_val
340
341 def test_get_symbol_from_address(self):
342 """Test GetSymbolFromAddress()"""
Stefan Herbrechtsmeier6ac7a832022-08-19 16:25:18 +0200343 if not elf.ELF_TOOLS:
344 self.skipTest('Python elftools not available')
Simon Glass40def8a2022-03-18 19:19:49 -0600345 fname = self.ElfTestFile('elf_sections')
346 sym_name = 'calculate'
347 syms = elf.GetSymbols(fname, [sym_name])
348 addr = syms[sym_name].address
349 sym = elf.GetSymbolFromAddress(fname, addr)
350 self.assertEqual(sym_name, sym)
351
352 def test_get_symbol_from_address_fail(self):
353 """Test calling GetSymbolFromAddress() without elftools"""
354 try:
355 old_val = elf.ELF_TOOLS
356 elf.ELF_TOOLS = False
357 fname = self.ElfTestFile('embed_data')
358 with self.assertRaises(ValueError) as e:
359 elf.GetSymbolFromAddress(fname, 0x1000)
360 self.assertIn("Python: No module named 'elftools'",
361 str(e.exception))
362 finally:
363 elf.ELF_TOOLS = old_val
364
Simon Glass39f4a852023-01-07 14:07:13 -0700365 def test_is_valid(self):
366 """Test is_valid()"""
367 self.assertEqual(False, elf.is_valid(b''))
368 self.assertEqual(False, elf.is_valid(b'1234'))
369
370 fname = self.ElfTestFile('elf_sections')
371 data = tools.read_file(fname)
372 self.assertEqual(True, elf.is_valid(data))
373 self.assertEqual(False, elf.is_valid(data[4:]))
374
Simon Glass060a65e2023-01-23 11:29:41 -0700375 def test_get_symbol_offset(self):
376 fname = self.ElfTestFile('embed_data')
377 syms = elf.GetSymbols(fname, ['embed_start', 'embed'])
378 expected = syms['embed'].address - syms['embed_start'].address
379 val = elf.GetSymbolOffset(fname, 'embed', 'embed_start')
380 self.assertEqual(expected, val)
381
382 with self.assertRaises(KeyError) as e:
383 elf.GetSymbolOffset(fname, 'embed')
384 self.assertIn('__image_copy_start', str(e.exception))
385
Simon Glasse1ad57e2023-07-18 07:24:01 -0600386 def test_get_symbol_address(self):
387 fname = self.ElfTestFile('embed_data')
388 addr = elf.GetSymbolAddress(fname, 'region_size')
389 self.assertEqual(0, addr)
390
Simon Glass19790632017-11-13 18:55:01 -0700391
Simon Glassb50e5612017-11-13 18:54:54 -0700392if __name__ == '__main__':
393 unittest.main()