objtool: Rename elf_open to prevent conflict with libelf from elftoolchain
PATCH 1/2 objtool: Rename elf_open to prevent conflict with libelf from elftoolchain
--- tools/objtool/check.c | 2 +- tools/objtool/elf.c | 2 +- tools/objtool/elf.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
tools/objtool/check.c +1 -1
@@ -2407,7 +2407,7 @@ int check(const char *_objname, bool orc) objname = _objname; - file.elf =elf_open (objname, orc ?O_RDWR :O_RDONLY ); + file.elf =elf_open_path (objname, orc ?O_RDWR :O_RDONLY );if (!file.elf)return 1 ;
tools/objtool/elf.c +1 -1
@@ -401,7 +401,7 @@ static int read_relas(struct elf *elf)return 0 ; } -struct elf *elf_open (const char *name,int flags) +struct elf *elf_open_path (const char *name,int flags) {struct elf *elf;Elf_Cmd cmd;
tools/objtool/elf.h +1 -1
@@ -74,7 +74,7 @@ struct elf { }; -struct elf *elf_open (const char *name,int flags); +struct elf *elf_open_path (const char *name,int flags);struct section *find_section_by_name (struct elf *elf,const char *name);struct symbol *find_symbol_by_offset (struct section *sec,unsigned long offset);struct symbol *find_symbol_by_name (struct elf *elf,const char *name);
Signature · 1 line
2.20.1
PATCH 2/2 objtool: Use Elf_Scn typedef instead of assuming tag name
The libelf implementation might use a different tag name, and the Elf_Scn typedef is already used throughout the rest of objtool.
--- tools/objtool/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/objtool/elf.c +1 -1
@@ -463,7 +463,7 @@ struct section *elf_create_section(struct elf *elf, const char *name, {struct section *sec, *shstrtab;size_t size = entsize * nr; -struct Elf_Scn *s; +Elf_Scn *s;Elf_Data *data; sec =malloc (sizeof (*sec));
Signature · 1 line
2.20.1
Quoted 6 lines · Michael Forney
Signed-off-by Michael Forney <[email protected]>--- tools/objtool/check.c | 2 +- tools/objtool/elf.c | 2 +- tools/objtool/elf.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Sorry for the delay, I was out for a bit and I'm still trying to get caught back up on email.
These patches look fine. I'll try to send them on to the -tip tree shortly.
Just curious, have you done much testing with the elftoolchain version of libelf and objtool? So far objtool has only been successfully used with the elfutils version, so I'm just curious how compatible your libelf is with the elfutils version.
Signature · 1 line
Josh
Quoted 10 lines · Josh Poimboeuf
Quoted 6 lines · Michael Forney
Signed-off-by Michael Forney <[email protected]>--- tools/objtool/check.c | 2 +- tools/objtool/elf.c | 2 +- tools/objtool/elf.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)Sorry for the delay, I was out for a bit and I'm still trying to get caught back up on email.
No worries :)
Quoted 2 lines
These patches look fine. I'll try to send them on to the -tip tree shortly.
Thanks!
Quoted 4 lines
Just curious, have you done much testing with the elftoolchain version of libelf and objtool? So far objtool has only been successfully used with the elfutils version, so I'm just curious how compatible your libelf is with the elfutils version.
I'm not affiliated with elftoolchain, I am just trying it out on my system as an alternative to elfutils libelf for its clean codebase that doesn't use many GNU C extensions.
I've done some basic testing to make sure that the .o files after being processed with objtool generate --no-fp --retpoline match between elfutils and elftoolchain. I noticed two differences, one of which was due to a bug in elftoolchain that has since been fixed, and the other is with the offset of SHT_NOBITS section after rewriting[0], which I think doesn't matter.
Quoted 28 lines · Michael Forney
Quoted 10 lines · Josh Poimboeuf
Quoted 6 lines · Michael Forney
Signed-off-by Michael Forney <[email protected]>--- tools/objtool/check.c | 2 +- tools/objtool/elf.c | 2 +- tools/objtool/elf.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)Sorry for the delay, I was out for a bit and I'm still trying to get caught back up on email.
No worries :)
Quoted 2 lines
These patches look fine. I'll try to send them on to the -tip tree shortly.
Thanks!
Quoted 4 lines
Just curious, have you done much testing with the elftoolchain version of libelf and objtool? So far objtool has only been successfully used with the elfutils version, so I'm just curious how compatible your libelf is with the elfutils version.
I'm not affiliated with elftoolchain, I am just trying it out on my system as an alternative to elfutils libelf for its clean codebase that doesn't use many GNU C extensions.
Quoted 6 lines
I've done some basic testing to make sure that the .o files after being processed with
objtool generate --no-fp --retpolinematch between elfutils and elftoolchain. I noticed two differences, one of which was due to a bug in elftoolchain that has since been fixed, and the other is with the offset ofSHT_NOBITSsection after rewriting[0], which I think doesn't matter.
Awesome, that gives me a lot more confidence. Thanks!
Signature · 1 line
Josh