This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] eblopenback: Warn when unable to find ebl backend

On Wed, 2015-11-25 at 23:51 +0100, Ben Gamari wrote:
> Mark Wielaard <> writes:
> > Yes, could you describe what kind of calls you were doing that made this
> > really messy?
> >
> Well, much of the time I spent debugging wasn't even against GHC. I
> spent quite a while trying to figure out why `readelf -r` thought all of
> my relocations were invalid. Since there was no debug output I had no
> choice but to step through the executable in GDB. It took me the better
> part of an hour to eventually realize that there was a typo in my

The problem is that ebl_openbackend never fails (except if you give it
an Elf from which the ehdr cannot be read), it returns a generic
"backend" when the backend cannot be found or there is some error
loading it. I wonder if we should just do this:

diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index b301400..ed16ef5 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -370,25 +370,11 @@ openbackend (Elf *elf, const char *emulation, GElf_Half machine)
            /* Not the module we need.  */
            (void) dlclose (h);
-       /* We cannot find a DSO but the emulation/machine ID matches.
-          Return that information.  */
-       result->dlhandle = NULL;
-       result->elf = elf;
-       result->name = machines[cnt].prefix;
-       fill_defaults (result);
-       return result;
-  /* Nothing matched.  We use only the default callbacks.   */
-  result->dlhandle = NULL;
-  result->elf = elf;
-  result->emulation = "<unknown>";
-  result->name = "<unknown>";
-  fill_defaults (result);
-  return result;
+  /* Unknown emulation/machine ID or we cannot find a DSO.  */
+  free (result);
+  return NULL;
The default openbackend should handle ebl == NULL just fine.
Then we just have to adjust the callers to either error out or just warn
about the unknown backend.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]