Hi guys,
Now when kexec-tools is in git I've taken some time to up port a few
fixes of mine. The patches all apply on top of commit
71d2424c8ac4f93a60c3eee5c95df269f584a9da. I'm unfortunately not aware
of the correct "standard" procedure to send kexec-tools patches, but I
hope attaching the patches is a good enough solution for now.
Cheers,
/ magnus
kexec-tools: make elf_rel_build_load() use buffer from argument
elf_rel_build_load() is currently using the symbols purgatory and
purgatory_size as buffer and buffer size instead of using the arguments
passed to the function. This patch fixes this by changing the code to
use the function arguments as buffer and buffer size.
Signed-off-by: Magnus Damm <[EMAIL PROTECTED]>
---
kexec-elf-rel.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/kexec/kexec-elf-rel.c b/kexec/kexec-elf-rel.c
index b55d2c2..8f7433c 100644
--- a/kexec/kexec-elf-rel.c
+++ b/kexec/kexec-elf-rel.c
@@ -417,7 +417,7 @@ void elf_rel_build_load(struct kexec_inf
int result;
/* Parse the Elf file */
- result = build_elf_rel_info((char *)purgatory, purgatory_size, ehdr);
+ result = build_elf_rel_info(buf, len, ehdr);
if (result < 0) {
die("ELF rel parse failed\n");
}
kexec-tools: teach elf_rel_load() about section names
The patch extends elf_rel_load() to handle section names correctly.
Signed-off-by: Magnus Damm <[EMAIL PROTECTED]>
---
kexec-elf-rel.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/kexec/kexec-elf-rel.c b/kexec/kexec-elf-rel.c
index b55d2c2..6e6baed 100644
--- a/kexec/kexec-elf-rel.c
+++ b/kexec/kexec-elf-rel.c
@@ -338,6 +338,7 @@ int elf_rel_load(struct mem_ehdr *ehdr,
struct mem_rela rel;
struct mem_sym sym;
const void *location;
+ const char *name;
unsigned long address, value, sec_base;
if (shdr->sh_type == SHT_REL) {
rel = elf_rel(ehdr, ptr);
@@ -353,9 +354,17 @@ int elf_rel_load(struct mem_ehdr *ehdr,
/* The relevant symbol */
sym = elf_sym(ehdr, symtab->sh_data + (rel.r_sym * elf_sym_size(ehdr)));
+
+ if (sym.st_name) {
+ name = strtab + sym.st_name;
+ }
+ else {
+ name = ehdr->e_shdr[ehdr->e_shstrndx].sh_data;
+ name += ehdr->e_shdr[sym.st_shndx].sh_name;
+ }
#ifdef DEBUG
fprintf(stderr, "sym: %10s info: %02x other: %02x shndx: %lx value: %lx size: %lx\n",
- strtab + sym.st_name,
+ name,
sym.st_info,
sym.st_other,
sym.st_shndx,
@@ -373,30 +382,28 @@ #endif
* So, is this really an error condition to flag die?
*/
/*
- die("Undefined symbol: %s\n",
- strtab + sym.st_name);
+ die("Undefined symbol: %s\n", name);
*/
continue;
}
sec_base = 0;
if (sym.st_shndx == SHN_COMMON) {
die("symbol: '%s' in common section\n",
- strtab + sym.st_name);
+ name);
}
else if (sym.st_shndx == SHN_ABS) {
sec_base = 0;
}
else if (sym.st_shndx > ehdr->e_shnum) {
die("Invalid section: %d for symbol %s\n",
- sym.st_shndx,
- strtab + sym.st_name);
+ sym.st_shndx, name);
}
else {
sec_base = ehdr->e_shdr[sym.st_shndx].sh_addr;
}
#ifdef DEBUG
fprintf(stderr, "sym: %s value: %lx addr: %lx\n",
- strtab + sym.st_name, value, address);
+ name, value, address);
#endif
value = sym.st_value;
value += sec_base;
kexec-tools: fix triple underscore typo in x86 and x86_64 code
Signed-off-by: Magnus Damm <[EMAIL PROTECTED]>
---
i386/kexec-elf-x86.c | 2 +-
x86_64/kexec-elf-x86_64.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
index 6308f4e..73b1576 100644
--- a/kexec/arch/i386/kexec-elf-x86.c
+++ b/kexec/arch/i386/kexec-elf-x86.c
@@ -149,7 +149,7 @@ #define OPT_ARGS_NONE (OPT_ARCH_MAX+4)
arg_style = ARG_STYLE_LINUX;
break;
case OPT_ARGS_NONE:
-#ifdef __i386___
+#ifdef __i386__
arg_style = ARG_STYLE_NONE;
#else
die("--args-none only works on arch i386\n");
diff --git a/kexec/arch/x86_64/kexec-elf-x86_64.c b/kexec/arch/x86_64/kexec-elf-x86_64.c
index e7272af..eff1fc9 100644
--- a/kexec/arch/x86_64/kexec-elf-x86_64.c
+++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
@@ -149,7 +149,7 @@ #define OPT_ARGS_NONE (OPT_ARCH_MAX+4)
arg_style = ARG_STYLE_LINUX;
break;
case OPT_ARGS_NONE:
-#ifdef __x86_64___
+#ifdef __x86_64__
arg_style = ARG_STYLE_NONE;
#else
die("--args-none only works on arch x86_64\n");
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot