Alan Modra <[EMAIL PROTECTED]> writes:
> On Tue, Aug 01, 2006 at 10:43:43PM -0600, Eric W. Biederman wrote:
>> Mohan Kumar M <[EMAIL PROTECTED]> writes:
>>
>> > Once again replying to Alan's correct email id.
>> >
>> > Please check for my reply at the end of mail.
>> >
>> > Sorry for the inconvenience.
>>
>> Ok. So from the looks of it we have a single toc and really are
>> not using the opd, at all. So if we can strip that out in the ppc
>> build that would be great. Otherwise it looks safe simply to ignore
>> relocations against the opd section. But just stripping the symbols
>> looks better.
>
> No, please don't discard .opd. If you do so, you'll break code that
> takes addresses of functions.
Currently in that part of kexec-tools we don't have any, and at the
moment we are already broken because we ignoring these relocations.
>> > Even though the .rela.opd section has undefined entries, we skipped
>> > applying relocation for these entries and the code is working as
>> > expected.
> [snip]
>> > 0000000000b8 000000000033 R_PPC64_TOC 0000000000000000
>
> I assume the "undefined" entry is the R_PPC64_TOC reloc above. When
> this relocation type has no symbol, it should resolve to the TOC pointer
> used in that object file.
That sounds reasonable. I have no problem with keeping things if we can
actually process them.
I do have an issue with weak symbols and want to make that an error
in this context. Because if we have them it is a programmer error,
and an all to easy mistake to make.
So it looks like I can make my sanity check for weak symbols a little
more specific and the Mohan can make certain we handle this case.
Mohan if I understand what is happening correctly this sufficiently
relaxes the check for weak symbols so you can process this relocation.
Can you try this and see if you can make this case work?
Eric
diff --git a/kexec/kexec-elf-rel.c b/kexec/kexec-elf-rel.c
index b55d2c2..af8debe 100644
--- a/kexec/kexec-elf-rel.c
+++ b/kexec/kexec-elf-rel.c
@@ -339,6 +339,7 @@ int elf_rel_load(struct mem_ehdr *ehdr,
struct mem_sym sym;
const void *location;
unsigned long address, value, sec_base;
+ unsigned type;
if (shdr->sh_type == SHT_REL) {
rel = elf_rel(ehdr, ptr);
}
@@ -363,26 +364,23 @@ #ifdef DEBUG
sym.st_size);
#endif
- if (sym.st_shndx == STN_UNDEF) {
- /*
- * NOTE: ppc64 elf .ro shows up a UNDEF section.
- * From Elf 1.2 Spec:
- * Relocation Entries: If the index is STN_UNDEF,
- * the undefined symbol index, the relocation uses 0
- * as the "symbol value".
- * So, is this really an error condition to flag die?
- */
- /*
+ /* Don't allow weak symbols */
+ type = ELF32_ST_TYPE(sym.st_info)
+ if ((sym.st_shndx == STN_UNDEF) && (
+ (type == STT_NOTYPE) || (type == STT_OBJECT) ||
+ (type == STT_FUNC) ||(type == STT_TLS)))
+ {
die("Undefined symbol: %s\n",
strtab + sym.st_name);
- */
- continue;
}
sec_base = 0;
if (sym.st_shndx == SHN_COMMON) {
die("symbol: '%s' in common section\n",
strtab + sym.st_name);
}
+ else if (sym.st_shndx == STN_UNDEF) {
+ sec_base = 0;
+ }
else if (sym.st_shndx == SHN_ABS) {
sec_base = 0;
}
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot