diff mbox series

[V2,01/15] selftests/x86/sgx: Fix a benign linker warning

Message ID 545aac243037bf5c2640929c4d8ff5c1edfe3ef8.1635447301.git.reinette.chatre@intel.com (mailing list archive)
State New
Headers show
Series selftests/sgx: Oversubscription, page permission, thread entry | expand

Commit Message

Reinette Chatre Oct. 28, 2021, 8:37 p.m. UTC
From: Sean Christopherson <sean.j.christopherson@intel.com>

Pass a build id of "none" to the linker to suppress a warning about the
build id being ignored:

  /usr/bin/ld: warning: .note.gnu.build-id section discarded, --build-id
  ignored.

Link: https://lore.kernel.org/linux-sgx/20191017030340.18301-2-sean.j.christopherson@intel.com/
Suggested-by: Cedric Xing <cedric.xing@intel.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
Changes since V1:
- Change Cedric's signature to a "Suggested-by" (Jarkko and Cedric).
- Add signatures from Jarkko and Dave.

 tools/testing/selftests/sgx/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dave Hansen Oct. 29, 2021, 12:26 a.m. UTC | #1
On 10/28/21 1:37 PM, Reinette Chatre wrote:
> From: Sean Christopherson <sean.j.christopherson@intel.com>
> 
> Pass a build id of "none" to the linker to suppress a warning about the
> build id being ignored:
> 
>   /usr/bin/ld: warning: .note.gnu.build-id section discarded, --build-id
>   ignored.

Do we have a good grasp on why this is producing a warning in the first
place?  This seems like something that could get merged quickly with one
more sentence in the changelog.
Sean Christopherson Oct. 29, 2021, 2:56 p.m. UTC | #2
On Thu, Oct 28, 2021, Dave Hansen wrote:
> On 10/28/21 1:37 PM, Reinette Chatre wrote:
> > From: Sean Christopherson <sean.j.christopherson@intel.com>
> > 
> > Pass a build id of "none" to the linker to suppress a warning about the
> > build id being ignored:
> > 
> >   /usr/bin/ld: warning: .note.gnu.build-id section discarded, --build-id
> >   ignored.
> 
> Do we have a good grasp on why this is producing a warning in the first
> place?  This seems like something that could get merged quickly with one
> more sentence in the changelog.

The SGX selftests use a custom linker script, tools/testing/selftests/sgx/test_encl.lds,
to configure the resulting enclave binary so that it's loadable as an enclave
more or less as-is.  One of the things the script does is drop sections the
selftests doesn't want, .note* sections being in that category.  I don't recall
exactly why the script drops sections; I assume it's to simply the loading process.
Anyways, .note.gnu.build-id is collateral damage and the linker complains.
Reinette Chatre Oct. 29, 2021, 5:09 p.m. UTC | #3
Hi Dave,

On 10/28/2021 5:26 PM, Dave Hansen wrote:
> On 10/28/21 1:37 PM, Reinette Chatre wrote:
>> From: Sean Christopherson <sean.j.christopherson@intel.com>
>>
>> Pass a build id of "none" to the linker to suppress a warning about the
>> build id being ignored:
>>
>>    /usr/bin/ld: warning: .note.gnu.build-id section discarded, --build-id
>>    ignored.
> 
> Do we have a good grasp on why this is producing a warning in the first
> place?  This seems like something that could get merged quickly with one
> more sentence in the changelog.
> 

How about a new changelog as below:

The enclave binary (test_encl.elf) is built with only three sections 
(tcs, text, and data) as controlled by its custom linker script.

If gcc is built with "--enable-linker-build-id" (this appears to be a 
common configuration even if it is by default off) then gcc will pass 
"--build-id" to the linker that will prompt it (the linker) to to write 
unique bits identifying the linked file to a ".note.gnu.build-id" section.

The section ".note.gnu.build-id" does not exist in the test enclave 
resulting in the following warning emitted by the linker:

/usr/bin/ld: warning: .note.gnu.build-id section discarded, --build-id 
ignored

The test enclave does not use the build id within the binary so fix the 
warning by passing a build id of "none" to the linker that will disable 
the setting from any earlier "--build-id" options and thus disable the 
attempt to write the build id to a ".note.gnu.build-id" section that 
does not exist.

Reinette
Dave Hansen Oct. 29, 2021, 5:11 p.m. UTC | #4
On 10/29/21 10:09 AM, Reinette Chatre wrote:
> On 10/28/2021 5:26 PM, Dave Hansen wrote:
>> On 10/28/21 1:37 PM, Reinette Chatre wrote:
>>> From: Sean Christopherson <sean.j.christopherson@intel.com>
>>>
>>> Pass a build id of "none" to the linker to suppress a warning about the
>>> build id being ignored:
>>>
>>>    /usr/bin/ld: warning: .note.gnu.build-id section discarded,
>>> --build-id
>>>    ignored.
>>
>> Do we have a good grasp on why this is producing a warning in the first
>> place?  This seems like something that could get merged quickly with one
>> more sentence in the changelog.
>>
> 
> How about a new changelog as below:
> 
> The enclave binary (test_encl.elf) is built with only three sections
> (tcs, text, and data) as controlled by its custom linker script.
> 
> If gcc is built with "--enable-linker-build-id" (this appears to be a
> common configuration even if it is by default off) then gcc will pass
> "--build-id" to the linker that will prompt it (the linker) to to write
> unique bits identifying the linked file to a ".note.gnu.build-id" section.
> 
> The section ".note.gnu.build-id" does not exist in the test enclave
> resulting in the following warning emitted by the linker:
> 
> /usr/bin/ld: warning: .note.gnu.build-id section discarded, --build-id
> ignored
> 
> The test enclave does not use the build id within the binary so fix the
> warning by passing a build id of "none" to the linker that will disable
> the setting from any earlier "--build-id" options and thus disable the
> attempt to write the build id to a ".note.gnu.build-id" section that
> does not exist.

Looks great, thanks for putting that together!
diff mbox series

Patch

diff --git a/tools/testing/selftests/sgx/Makefile b/tools/testing/selftests/sgx/Makefile
index 7f12d55b97f8..2956584e1e37 100644
--- a/tools/testing/selftests/sgx/Makefile
+++ b/tools/testing/selftests/sgx/Makefile
@@ -45,7 +45,7 @@  $(OUTPUT)/sign_key.o: sign_key.S
 	$(CC) $(HOST_CFLAGS) -c $< -o $@
 
 $(OUTPUT)/test_encl.elf: test_encl.lds test_encl.c test_encl_bootstrap.S
-	$(CC) $(ENCL_CFLAGS) -T $^ -o $@
+	$(CC) $(ENCL_CFLAGS) -T $^ -o $@ -Wl,--build-id=none
 
 EXTRA_CLEAN := \
 	$(OUTPUT)/test_encl.elf \