From bd56ca48be81763872d1562822b94843eed12fdc Mon Sep 17 00:00:00 2001 From: Valerii Koval Date: Tue, 23 Jan 2024 14:45:52 +0200 Subject: [PATCH 1/2] fix(ldgen): handle object files with .*.o patterns Currently, only `.o`, `.*.obj` and `.obj` patterns are taken into account. It would be great to have object files with the `.*.o` extension pattern (e.g. `file.cpp.o`) also processed as they're quite widespread in third-party integrations. --- tools/ldgen/ldgen/entity.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/ldgen/ldgen/entity.py b/tools/ldgen/ldgen/entity.py index aecdcab91b..659898f370 100644 --- a/tools/ldgen/ldgen/entity.py +++ b/tools/ldgen/ldgen/entity.py @@ -181,7 +181,8 @@ class EntityDB: def _match_obj(self, archive, obj): objs = self.get_objects(archive) - match_objs = (fnmatch.filter(objs, obj + '.o') + match_objs = (fnmatch.filter(objs, obj + '.*.o') + + fnmatch.filter(objs, obj + '.o') + fnmatch.filter(objs, obj + '.*.obj') + fnmatch.filter(objs, obj + '.obj')) From 65373e126a714e829802cebbaf6f60975387445c Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Thu, 25 Jan 2024 17:40:40 +0800 Subject: [PATCH 2/2] test(ldgen): added test simulating a .*.c file --- tools/ldgen/test/data/test_entity/parse_test.txt | 7 +++++++ tools/ldgen/test/test_entity.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/tools/ldgen/test/data/test_entity/parse_test.txt b/tools/ldgen/test/data/test_entity/parse_test.txt index 4357f02032..aa3f44b966 100644 --- a/tools/ldgen/test/data/test_entity/parse_test.txt +++ b/tools/ldgen/test/data/test_entity/parse_test.txt @@ -17,3 +17,10 @@ Sections: Idx Name Size VMA LMA File off Algn 0 .literal.ěščřžýáíé 00000018 00000000 00000000 00000034 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE + +o_suffix.c.o: file format elf32-littleriscv + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .find_me 00000000 00000000 00000000 00000034 2**0 + CONTENTS, ALLOC, LOAD, READONLY, CODE diff --git a/tools/ldgen/test/test_entity.py b/tools/ldgen/test/test_entity.py index 0f297157a8..25ac8b6c61 100755 --- a/tools/ldgen/test/test_entity.py +++ b/tools/ldgen/test/test_entity.py @@ -236,6 +236,9 @@ class EntityDBTest(unittest.TestCase): sections = self.entities.get_sections('ěščřžýáíé.a', 'FreeRTOS-ěščřžýáíé') self.assertEqual(set(sections), set(['.literal.ěščřžýáíé'])) + sections = self.entities.get_sections('ěščřžýáíé.a', 'o_suffix') + self.assertEqual(set(sections), set(['.find_me'])) + if __name__ == '__main__': unittest.main()