All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH] tests/x86emul: Annotate test blobs as executable code
Date: Fri, 24 May 2019 09:50:27 -0600	[thread overview]
Message-ID: <5CE812C3020000780023219E@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <1558710904-8210-1-git-send-email-andrew.cooper3@citrix.com>

>>> On 24.05.19 at 17:15, <andrew.cooper3@citrix.com> wrote:
> --- a/tools/tests/x86_emulator/Makefile
> +++ b/tools/tests/x86_emulator/Makefile
> @@ -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 "};") >>$@.new; \
> +		 echo "}; asm(\".type $${prefix}_$(arch)$${flavor}, STT_FUNC;\");") >>$@.new; \

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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

WARNING: multiple messages have this Message-ID (diff)
From: "Jan Beulich" <JBeulich@suse.com>
To: "Andrew Cooper" <andrew.cooper3@citrix.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH] tests/x86emul: Annotate test blobs as executable code
Date: Fri, 24 May 2019 09:50:27 -0600	[thread overview]
Message-ID: <5CE812C3020000780023219E@prv1-mh.provo.novell.com> (raw)
Message-ID: <20190524155027.Hr95i9DjEzrQ3sHEzwDpNY95SY5rLoBKF0rQlsIttqQ@z> (raw)
In-Reply-To: <1558710904-8210-1-git-send-email-andrew.cooper3@citrix.com>

>>> On 24.05.19 at 17:15, <andrew.cooper3@citrix.com> wrote:
> --- a/tools/tests/x86_emulator/Makefile
> +++ b/tools/tests/x86_emulator/Makefile
> @@ -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 "};") >>$@.new; \
> +		 echo "}; asm(\".type $${prefix}_$(arch)$${flavor}, STT_FUNC;\");") >>$@.new; \

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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-05-24 15:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 15:15 [PATCH] tests/x86emul: Annotate test blobs as executable code Andrew Cooper
2019-05-24 15:15 ` [Xen-devel] " Andrew Cooper
2019-05-24 15:50 ` Jan Beulich [this message]
2019-05-24 15:50   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5CE812C3020000780023219E@prv1-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.