https://sourceware.org/bugzilla/show_bug.cgi?id=32540
--- Comment #2 from Michael Tremer <michael.tremer at ipfire dot org> ---
Hello Mark,
thank you for getting back to me on this.
I did notice the string function, but how would I programmatically check what
kind of error was returned? String matching does not sound like a safe option.
My code looks like this:
> // Read DWARF information
> dwarf = dwarf_begin(self->fd, DWARF_C_READ);
> if (!dwarf) {
> switch (dwarf_errno()) {
> // If we don't have any DWARF information there is
> nothing to do
> case DWARF_E_NO_DWARF:
> r = 0;
> goto ERROR;
>
> default:
> ERROR(self->ctx, "Could not initialize DWARF
> context: %s\n", dwarf_errmsg(-1));
> r = -errno;
> goto ERROR;
> }
> }
I am basically trying to extract any source information before I am stripping
the binary. Sometimes there is no DWARF information. From the NULL pointer that
is being returned by dward_begin() I cannot tell whether there has been an
error, or genuinely no DWARF information was found - which in my case is an
acceptable outcome.
A bit further into my routine I have a similar case:
> // Fetch the source files
> r = dwarf_getsrcfiles(die, &files, &count);
> if (r < 0) {
> switch (dwarf_errno()) {
> // Skip any invalid DWARF sections
> case DWARF_E_INVALID_DWARF:
> goto NEXT;
>
> default:
> ERROR(self->ctx, "Could not fetch the
> source files for %s: %s\n",
> self->path, dwarf_errmsg(-1));
> r = -ENOTSUP;
> goto ERROR;
> }
> }
Some files, if I remember correctly glibc start files, can get opened, but
there seem to be some sections that cannot be parsed. As extracting the source
is best-effort anyways, I would like to skip them and the error code allows me
to.
My full code is here:
https://git.ipfire.org/?p=pakfire.git;a=blob;f=src/pakfire/elf.c;hb=ec4278ae949bcd5a73e47448afe404d187d89be2#l1127
As a workaround I have been defining the two codes that I am currently using,
but of course that won't be a stable solution for the future.
I hope I could explain my use case a little bit more and there is a chance to
export those error codes.
--
You are receiving this mail because:
You are on the CC list for the bug.