FILE* f = NULL;
int r;
+ char** argv = NULL;
+
int extract_debuginfo = 1;
// Check whether we should extract debug information
goto ERROR;
}
- // Extract the debug information
- if (extract_debuginfo) {
- r = pakfire_stripper_extract_debuginfo(self, file, elf, build_id_path);
- if (r < 0)
- goto ERROR;
- }
-
- const char* strip_argv[] = {
+ const char* strip[] = {
"objcopy",
// Ask to strip all debug information
"--remove-section=.gnu.debuglto_*",
"--strip-symbol=__gnu_lto_v1",
- // Add the debuglink
+ // Remove any previous debuglinks
"--remove-section=.gnu_debuglink",
- "--add-gnu-debuglink", build_id_path,
// The source file
path,
NULL,
};
+ // Compose the commandline
+ r = pakfire_strings_appendm(&argv, strip);
+ if (r < 0)
+ goto ERROR;
+
+ // Extract the debug information
+ if (extract_debuginfo) {
+ r = pakfire_stripper_extract_debuginfo(self, file, elf, build_id_path);
+ if (r < 0)
+ goto ERROR;
+
+ // Add the debuglink
+ r = pakfire_strings_appendf(&argv, "--add-gnu-debuglink=%s", build_id_path);
+ if (r < 0)
+ goto ERROR;
+ }
+
// Run the command
- r = pakfire_jail_exec_command(self->jail, strip_argv, NULL, 0);
+ r = pakfire_jail_exec_command(self->jail, (const char**)argv, NULL, 0);
if (r < 0) {
ERROR(self->ctx, "Could not strip debug sections from %s: %s\n",
pakfire_file_get_path(file), strerror(-r));
goto ERROR;
ERROR:
+ if (argv)
+ pakfire_strings_free(argv);
if (*tmppath)
unlink(tmppath);
if (f)