Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1732581 > unrolled thread

Re: "objtool orc" creates invalid file arch/x86/kernel/time.o

Started byJosh Poimboeuf <jpoimboe@redhat.com>
First post2017-09-14 23:10 +0200
Last post2017-09-15 00:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: "objtool orc" creates invalid file arch/x86/kernel/time.o Josh Poimboeuf <jpoimboe@redhat.com> - 2017-09-14 23:10 +0200
    Re: "objtool orc" creates invalid file arch/x86/kernel/time.o Arnd Bergmann <arnd@arndb.de> - 2017-09-14 23:50 +0200
      Re: "objtool orc" creates invalid file arch/x86/kernel/time.o Arnd Bergmann <arnd@arndb.de> - 2017-09-15 00:10 +0200

#1732581 — Re: "objtool orc" creates invalid file arch/x86/kernel/time.o

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2017-09-14 23:10 +0200
SubjectRe: "objtool orc" creates invalid file arch/x86/kernel/time.o
Message-ID<upJyz-1Kz-33@gated-at.bofh.it>
On Sun, Sep 10, 2017 at 10:38:58PM +0200, Arnd Bergmann wrote:
> Hi Josh,
> 
> I have a randconfig build that produces a link error:
> 
> built-in.o: member arch/x86/kernel/time.o in archive is not an object
> 
> I've traced it down to the "objtool orc generate" command that appears
> to corrupt the file, by running the same commands that 'make' calls:

Thanks, I was able to recreate with your config.  I'll post the patch
soon (here's the preview):

---

From: Josh Poimboeuf <jpoimboe@redhat.com>
Subject: [PATCH] objtool: Fix object file corruption

Arnd Bergmann reported that a randconfig build was failing with the
following link error:

  built-in.o: member arch/x86/kernel/time.o in archive is not an object

It turns out the link failed because the time.o file had been corrupted
by objtool:

  nm: arch/x86/kernel/time.o: File format not recognized

In certain rare cases, when a .o file's ORC table is very small, the
.data section size doesn't change because it's page aligned.  Because
all the existing sections haven't changed size, libelf doesn't detect
any section header changes, and so it doesn't update the section header
table properly.  Instead it writes junk in the section header entries
for the new ORC sections.

Make sure libelf properly updates the section header table by setting
the ELF_F_DIRTY flag in the top level elf struct.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 627fce14809b ("objtool: Add ORC unwind table generation")
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 tools/objtool/elf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 6e9f980a7d26..780d02af957d 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -561,6 +561,7 @@ int elf_write(struct elf *elf)
 	struct section *sec;
 	Elf_Scn *s;
 
+	/* Update section headers for changed sections: */
 	list_for_each_entry(sec, &elf->sections, list) {
 		if (sec->changed) {
 			s = elf_getscn(elf->elf, sec->idx);
@@ -568,13 +569,17 @@ int elf_write(struct elf *elf)
 				WARN_ELF("elf_getscn");
 				return -1;
 			}
-			if (!gelf_update_shdr (s, &sec->sh)) {
+			if (!gelf_update_shdr(s, &sec->sh)) {
 				WARN_ELF("gelf_update_shdr");
 				return -1;
 			}
 		}
 	}
 
+	/* Make sure the new section header entries get updated properly. */
+	elf_flagelf(elf->elf, ELF_C_SET, ELF_F_DIRTY);
+
+	/* Write all changes to the file. */
 	if (elf_update(elf->elf, ELF_C_WRITE) < 0) {
 		WARN_ELF("elf_update");
 		return -1;
-- 
2.13.5

[toc] | [next] | [standalone]


#1732603

FromArnd Bergmann <arnd@arndb.de>
Date2017-09-14 23:50 +0200
Message-ID<upKbg-1XT-3@gated-at.bofh.it>
In reply to#1732581
On Thu, Sep 14, 2017 at 11:00 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Sun, Sep 10, 2017 at 10:38:58PM +0200, Arnd Bergmann wrote:
>> Hi Josh,
>>
>> I have a randconfig build that produces a link error:
>>
>> built-in.o: member arch/x86/kernel/time.o in archive is not an object
>>
>> I've traced it down to the "objtool orc generate" command that appears
>> to corrupt the file, by running the same commands that 'make' calls:
>
> Thanks, I was able to recreate with your config.  I'll post the patch
> soon (here's the preview):

Ok, thanks! I've added it to my randconfig test tree. With this build error,
I now have three failing configs, two with the same file, and another one
in a timer driver. I'll see if the patch addresses all three of them, but
won't have the results until tomorrow.

      Arnd

[toc] | [prev] | [next] | [standalone]


#1732611

FromArnd Bergmann <arnd@arndb.de>
Date2017-09-15 00:10 +0200
Message-ID<upKuB-2je-1@gated-at.bofh.it>
In reply to#1732603
On Thu, Sep 14, 2017 at 11:44 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thu, Sep 14, 2017 at 11:00 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
>> On Sun, Sep 10, 2017 at 10:38:58PM +0200, Arnd Bergmann wrote:
>>> Hi Josh,
>>>
>>> I have a randconfig build that produces a link error:
>>>
>>> built-in.o: member arch/x86/kernel/time.o in archive is not an object
>>>
>>> I've traced it down to the "objtool orc generate" command that appears
>>> to corrupt the file, by running the same commands that 'make' calls:
>>
>> Thanks, I was able to recreate with your config.  I'll post the patch
>> soon (here's the preview):
>
> Ok, thanks! I've added it to my randconfig test tree. With this build error,
> I now have three failing configs, two with the same file, and another one
> in a timer driver. I'll see if the patch addresses all three of them, but
> won't have the results until tomorrow.

I guess it must be 'tomorrow' in my time zone now ;-)

The patch fixed all three configurations.

       Arnd

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web