diff --git a/src/system/runtime_loader/elf_symbol_lookup.cpp b/src/system/runtime_loader/elf_symbol_lookup.cpp index 5ccd554df8..b2f6d16a04 100644 --- a/src/system/runtime_loader/elf_symbol_lookup.cpp +++ b/src/system/runtime_loader/elf_symbol_lookup.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -401,6 +401,24 @@ find_undefined_symbol_add_on(image_t* rootImage, image_t* image, // library symbol references to symbol definitions in the add-on, as // libraries can be shared between different add-ons and we must not // introduce connections between add-ons. + + // For the add-on image itself resolve non-weak symbols defined in the + // add-on to themselves. This makes the symbol resolution order inconsistent + // for those symbols, but avoids clashes of global symbols defined in the + // add-on with symbols defined e.g. in the application. There's really the + // same problem for weak symbols, but we don't have any way to discriminate + // weak symbols that must be resolved globally from those that should be + // resolved within the add-on. + if (rootImage == image) { + if (Elf32_Sym* symbol = lookupInfo.requestingSymbol) { + if (symbol->st_shndx != SHN_UNDEF + && (ELF32_ST_BIND(symbol->st_info) == STB_GLOBAL)) { + *_foundInImage = image; + return symbol; + } + } + } + image_t* candidateImage = NULL; Elf32_Sym* candidateSymbol = NULL;