Skip to contentSkip to conversation

tests/x86emul: Annotate test blobs as executable code

PATCH In review Andrew Cooper 2 participants 2 messages May 24, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/x86emul: Annotate test blobs as executable code

This causes objdump to disassemble them, rather than rendering them as straight hex data.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 tools/tests/x86_emulator/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/tests/x86_emulator/Makefile +2 -2
index 970ec3e..b54603d 100644
@@ -149,7 +149,7 @@ $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile
 		(echo 'static const unsigned int __attribute__((section(".test, \"ax\", @progbits #")))' \
 		      "$${prefix}_$(arch)$${flavor}[] = {"; \
 		 od -v -t x $*.bin | sed -e 's/^[0-9]* /0x/' -e 's/ /, 0x/g' -e 's/$$/,/'; \
-		 echo "};") >>[email protected]; \
+		 echo "}; asm(\".type $${prefix}_$(arch)$${flavor}, STT_FUNC;\");") >>[email protected]; \
 		rm -f $*.bin; \
 	    done; \
 	)
@@ -165,7 +165,7 @@ $(addsuffix -opmask.h,$(OPMASK)): %.h: opmask.S testcase.mk Makefile
 		(echo 'static const unsigned int __attribute__((section(".test, \"ax\", @progbits #")))' \
 		      "$${prefix}_$(arch)$${flavor}[] = {"; \
 		 od -v -t x $*.bin | sed -e 's/^[0-9]* /0x/' -e 's/ /, 0x/g' -e 's/$$/,/'; \
-		 echo "};") >>[email protected]; \
+		 echo "}; asm(\".type $${prefix}_$(arch)$${flavor}, STT_FUNC;\");") >>[email protected]; \
 		rm -f $*.bin; \
 	    done; \
 	)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

tools/tests/x86_emulator/Makefile $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile · line 152

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.05.19 at 17:15, <[email protected]> wrote:
tools/tests/x86_emulator/Makefile +1 -1
@@ -149,7 +149,7 @@ $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile
 		(echo 'static const unsigned int __attribute__((section(".test, \"ax\", @progbits #")))' \
 		      "$${prefix}_$(arch)$${flavor}[] = {"; \
 		 od -v -t x $*.bin | sed -e 's/^[0-9]* /0x/' -e 's/ /, 0x/g' -e 's/$$/,/'; \
-		 echo "};") >>[email protected]; \
+		 echo "}; asm(\".type $${prefix}_$(arch)$${flavor}, STT_FUNC;\");") >>[email protected]; \

Hmm, this seems risky to me - I'd expect a decent compiler to mark them as STT_OBJECT, and a decent assembler to choke on finding disagreeing .type directives for the same symbol. Current binutils looks to simply OR together all the values, and then decide in an adhoc sequence which type to actually emit:

      if ((flags & BSF_THREAD_LOCAL) != 0)
	type = STT_TLS;
      else if ((flags & BSF_GNU_INDIRECT_FUNCTION) != 0)
	type = STT_GNU_IFUNC;
      else if ((flags & BSF_FUNCTION) != 0)
	type = STT_FUNC;
      else if ((flags & BSF_OBJECT) != 0)
	type = STT_OBJECT;
      else if ((flags & BSF_RELC) != 0)
	type = STT_RELC;
      else if ((flags & BSF_SRELC) != 0)
	type = STT_SRELC;
      else
	type = STT_NOTYPE;

I don't think that's sane behavior (albeit it guarantees @function to win over @object), and hence I'd say it can change at any time.

I wanted to suggest forcing the type change via objcopy, but to my surprise I couldn't find a respective option.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel