Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageTool: Add debug symbols path argument #52

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BaseTools/Conf/build_rule.template
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
$(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
$(OBJCOPY) $(OBJCOPY_STRIPFLAG) $(DEBUG_DIR)(+)$(MODULE_NAME).strip

ImageTool GenImage -c PE -x -t $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
ImageTool GenImage -c PE -x -t $(MODULE_TYPE) -d ${src} -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).strip

$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
Expand Down
20 changes: 18 additions & 2 deletions BaseTools/ImageTool/ImageTool.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ RETURN_STATUS
GenExecutable (
IN const char *OutputFileName,
IN const char *InputFileName,
IN const char *SymbolsPath OPTIONAL,
IN const char *FormatName,
IN const char *TypeName,
IN const char *BaseAddress,
Expand Down Expand Up @@ -397,6 +398,10 @@ GenExecutable (
return RETURN_ABORTED;
}

if (SymbolsPath == NULL) {
SymbolsPath = InputFileName;
}

OutputFile = ToolImageEmit (
&OutputFileSize,
InputFile,
Expand All @@ -405,7 +410,7 @@ GenExecutable (
Type,
BaseAddress != NULL,
NewBaseAddress,
InputFileName,
SymbolsPath,
Xip,
Strip,
FixedAddress
Expand All @@ -429,6 +434,7 @@ int main (int argc, const char *argv[])
UINT32 NumOfFiles;
const char *OutputName;
const char *InputName;
const char *SymbolsPath;
const char *FormatName;
const char *TypeName;
const char *BaseAddress;
Expand All @@ -450,13 +456,14 @@ int main (int argc, const char *argv[])
if (strcmp (argv[1], "GenImage") == 0) {
if (argc < 5) {
fprintf (stderr, "ImageTool: Command arguments are missing\n");
fprintf (stderr, " Usage: ImageTool GenImage [-c Format] [-t ModuleType] [-b BaseAddress] [-x] [-s] [-f] -o OutputFile InputFile\n");
fprintf (stderr, " Usage: ImageTool GenImage [-c Format] [-t ModuleType] [-b BaseAddress] [-d SymbolsPath] [-x] [-s] [-f] -o OutputFile InputFile\n");
DEBUG_RAISE ();
return -1;
}

OutputName = NULL;
InputName = NULL;
SymbolsPath = NULL;
FormatName = NULL;
TypeName = NULL;
BaseAddress = NULL;
Expand Down Expand Up @@ -496,6 +503,14 @@ int main (int argc, const char *argv[])
}

BaseAddress = argv[ArgIndex];
} else if (strcmp (argv[ArgIndex], "-d") == 0) {
++ArgIndex;
if (ArgIndex == argc) {
fprintf (stderr, "Must specify an argument to -d\n");
return -1;
}

SymbolsPath = argv[ArgIndex];
} else if (strcmp (argv[ArgIndex], "-x") == 0) {
Xip = true;
} else if (strcmp (argv[ArgIndex], "-s") == 0) {
Expand Down Expand Up @@ -525,6 +540,7 @@ int main (int argc, const char *argv[])
Status = GenExecutable (
OutputName,
InputName,
SymbolsPath,
FormatName,
TypeName,
BaseAddress,
Expand Down