insane: detect and warn about relocations in .text
Ping?
Quoted 52 lines · Phil Blundell
Signed-off-by Phil Blundell <[email protected]>---
This requiresqa.elf.run_objdump()so needs to be applied after the patch which adds that function.meta/classes/insane.bbclass | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)meta/classes/insane.bbclass +25
-1@@ -108,7 +108,7 @@ def package_qa_get_machine_dict(): # Currently not being used by default "desktop" -WARN_QA ?= "ldflags useless-rpaths rpaths unsafe-references-in-binaries unsafe-references-in-scripts staticdev libdir" +WARN_QA ?= "ldflags useless-rpaths rpaths unsafe-references-in-binaries unsafe-references-in-scripts staticdev libdir textrel" ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch la2 pkgconfig la perms dep-cmp" ALL_QA = "${WARN_QA} ${ERROR_QA}"@@ -421,6 +421,30 @@ def package_qa_check_desktop(path, name, d, elf, messages): for l in output: messages.append("Desktop file issue: " + l.strip()) +QAPATHTEST[textrel] = "package_qa_textrel" +def package_qa_textrel(path, name, d, elf, messages): + """ + Check if the binary contains relocations in .text + """ + + if not elf: + return + + if os.path.islink(path): + return + + phdrs = elf.run_objdump("-p", d) + sane = True + + import re + textrel_re = re.compile("\s+TEXTREL\s+") + for line in phdrs.split("\n"): + if textrel_re.match(line): + sane = False + + if not sane: + messages.append("ELF binary '%s' has relocations in .text" % path) + QAPATHTEST[ldflags] = "package_qa_hash_style" def package_qa_hash_style(path, name, d, elf, messages): """
Quoted 1 line · Phil Blundell
Ping?
I do think we need this. Having the textrel does prevent prelinking as well.
--Mark
Quoted 61 lines · Phil Blundell
Quoted 42 lines
Signed-off-by Phil Blundell <[email protected]>---
This requiresqa.elf.run_objdump()so needs to be applied after the patch which adds that function.meta/classes/insane.bbclass | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)meta/classes/insane.bbclass +18
-1@@ -108,7 +108,7 @@ def package_qa_get_machine_dict(): # Currently not being used by default "desktop" -WARN_QA ?= "ldflags useless-rpaths rpaths unsafe-references-in-binaries unsafe-references-in-scripts staticdev libdir" +WARN_QA ?= "ldflags useless-rpaths rpaths unsafe-references-in-binaries unsafe-references-in-scripts staticdev libdir textrel" ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch la2 pkgconfig la perms dep-cmp" ALL_QA = "${WARN_QA} ${ERROR_QA}"@@ -421,6 +421,30 @@ def package_qa_check_desktop(path, name, d, elf, messages): for l in output: messages.append("Desktop file issue: " + l.strip()) +QAPATHTEST[textrel] = "package_qa_textrel" +def package_qa_textrel(path, name, d, elf, messages): + """ + Check if the binary contains relocations in .text + """ + + if not elf: + return + + if os.path.islink(path): + return + + phdrs = elf.run_objdump("-p", d) + sane = True + + import re + textrel_re = re.compile("\s+TEXTREL\s+")meta/classes/insane.bbclass def package_qa_check_desktop(path, name, d, elf, messages): · line 450
Quoted 10 lines
meta/classes/insane.bbclass +7
-0+ for line in phdrs.split("\n"): + if textrel_re.match(line): + sane = False + + if not sane: + messages.append("ELF binary '%s' has relocations in .text" % path) + QAPATHTEST[ldflags] = "package_qa_hash_style" def package_qa_hash_style(path, name, d, elf, messages): """_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Quoted 4 lines · Mark Hatle
Quoted 1 line · Phil Blundell
Ping?
I do think we need this. Having the textrel does prevent prelinking as well.
Coming up to release I didn't really want to add more warnings and its slipped through the cracks. I'll likely take this next week when things quieten down a bit, ELC-E, the OE-GA, Yocto Project Dev day and so on are making this one a little hectic.
Does anyone know how many warnings this is going to generate on an OE-Core world build?
The biggest issue I have with these new tests is people also stepping up and fixing the warnings they generate since often its a non-trivial effort. The Yocto Project has been doing a lot here, quietly fixing a lot of them up but more help would be much appreciated.
Cheers,
Richard