|
@@ -100,7 +100,7 @@ ELF_LIBRARY_PATH_VARIABLE_ENTRY ElfLibraryPathVariables[] = {
|
|
|
|
|
|
KSTATUS
|
|
|
ImpElfOpenWithPathList (
|
|
|
- PLOADED_IMAGE Parent,
|
|
|
+ PLOADED_IMAGE PathImage,
|
|
|
PCSTR LibraryName,
|
|
|
PSTR PathList,
|
|
|
PIMAGE_FILE_INFORMATION File,
|
|
@@ -115,7 +115,9 @@ Routine Description:
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
- Parent - Supplies a pointer to the image that needs the library.
|
|
|
+ PathImage - Supplies a pointer to the image that owns the path list. This
|
|
|
+ will be the image that needs the library or an ancestor of the image
|
|
|
+ that needs the library.
|
|
|
|
|
|
LibraryName - Supplies the name of the library to load.
|
|
|
|
|
@@ -192,7 +194,7 @@ Return Value:
|
|
|
LibraryLength);
|
|
|
|
|
|
CompletePath[PrefixLength + LibraryLength] = '\0';
|
|
|
- Status = ImpElfPerformLibraryPathSubstitutions(Parent,
|
|
|
+ Status = ImpElfPerformLibraryPathSubstitutions(PathImage,
|
|
|
&CompletePath,
|
|
|
&CompletePathCapacity);
|
|
|
|
|
@@ -200,7 +202,7 @@ Return Value:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- Status = ImOpenFile(Parent->SystemContext, CompletePath, File);
|
|
|
+ Status = ImOpenFile(PathImage->SystemContext, CompletePath, File);
|
|
|
if (KSUCCESS(Status)) {
|
|
|
break;
|
|
|
}
|
|
@@ -352,7 +354,7 @@ Return Value:
|
|
|
|
|
|
KSTATUS
|
|
|
ImpElfPerformLibraryPathSubstitutions (
|
|
|
- PLOADED_IMAGE Image,
|
|
|
+ PLOADED_IMAGE PathImage,
|
|
|
PSTR *Path,
|
|
|
PUINTN PathCapacity
|
|
|
)
|
|
@@ -365,8 +367,8 @@ Routine Description:
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
- Image - Supplies a pointer to the image loading the library (not the
|
|
|
- library itself obviously, that hasn't been loaded yet).
|
|
|
+ PathImage - Supplies a pointer to the image that owns the library path (not
|
|
|
+ the library itself obviously, that hasn't been loaded yet).
|
|
|
|
|
|
Path - Supplies a pointer that on input contains the complete path. On
|
|
|
output this will contain the complete path with variables expanded.
|
|
@@ -398,6 +400,7 @@ Return Value:
|
|
|
UINTN RemainderOffset;
|
|
|
PSTR Replacement;
|
|
|
UINTN ReplacementLength;
|
|
|
+ PSTR Separator;
|
|
|
KSTATUS Status;
|
|
|
UINTN VariableLength;
|
|
|
UINTN VariableOffset;
|
|
@@ -461,24 +464,59 @@ Return Value:
|
|
|
Name);
|
|
|
|
|
|
} else {
|
|
|
+ ReplacementLength = 0;
|
|
|
+ switch (Entry->Variable) {
|
|
|
+ case ElfLibraryPathOrigin:
|
|
|
+ Separator = RtlStringFindCharacterRight(PathImage->FileName,
|
|
|
+ '/',
|
|
|
+ -1);
|
|
|
|
|
|
- //
|
|
|
- // TODO: Get the correct variable values.
|
|
|
- //
|
|
|
+ if (Separator != NULL) {
|
|
|
+ Replacement = PathImage->FileName;
|
|
|
+ ReplacementLength = (UINTN)Separator - (UINTN)Replacement;
|
|
|
|
|
|
- ASSERT(FALSE);
|
|
|
+ } else {
|
|
|
+ Replacement = ".";
|
|
|
+ }
|
|
|
|
|
|
- switch (Entry->Variable) {
|
|
|
- case ElfLibraryPathOrigin:
|
|
|
- Replacement = ".";
|
|
|
break;
|
|
|
|
|
|
case ElfLibraryPathLib:
|
|
|
- Replacement = "lib";
|
|
|
+ if (PathImage->Format == ImageElf64) {
|
|
|
+ Replacement = "lib64";
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Replacement = "lib";
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case ElfLibraryPathPlatform:
|
|
|
- Replacement = "i386";
|
|
|
+ switch (PathImage->Machine) {
|
|
|
+ case ImageMachineTypeX86:
|
|
|
+ Replacement = "i686";
|
|
|
+ break;
|
|
|
+
|
|
|
+ case ImageMachineTypeX64:
|
|
|
+ Replacement = "x86_64";
|
|
|
+ break;
|
|
|
+
|
|
|
+ case ImageMachineTypeArm32:
|
|
|
+ Replacement = "armv7";
|
|
|
+ break;
|
|
|
+
|
|
|
+ case ImageMachineTypeArm64:
|
|
|
+ Replacement = "armv8";
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+
|
|
|
+ ASSERT(FALSE);
|
|
|
+
|
|
|
+ Replacement = ".";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
default:
|
|
@@ -489,7 +527,9 @@ Return Value:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- ReplacementLength = RtlStringLength(Replacement);
|
|
|
+ if (ReplacementLength == 0) {
|
|
|
+ ReplacementLength = RtlStringLength(Replacement);
|
|
|
+ }
|
|
|
|
|
|
//
|
|
|
// If the replacement is shorter than the original variable, then
|