This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc 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]

[Bug dynamic-link/11754] RFE: dlopen of ET_EXEC file


https://sourceware.org/bugzilla/show_bug.cgi?id=11754

--- Comment #15 from Florian Weimer <fweimer at redhat dot com> ---
(In reply to John Reiser from comment #14)
> (In reply to Florian Weimer from comment #13)
> > We cannot support this because it is not possible to perform correct
> > relocations if another executable has already been loaded.  There is also no
> > way to correctly execute the ELF constructors of the second executable.
> 
> Please give specific examples or explanations why success (or a
> recognizable, specific, and informative error code) is not possible.

Here is an example.  The first program is mylocaltime-export:

#include <stdio.h>
#include <time.h>

void
mylocaltime (time_t t)
{
  struct tm *tm = localtime (&t);
  printf ("tm_isdst (from other program): %d\n", tm->tm_isdst);
  printf ("daylight (from other program): %d\n", daylight);
}

int
main (void)
{
  return 0;
}

The second is mylocaltime-use:

#include <dlfcn.h>
#include <err.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

static void
mylocaltime2 (time_t t)
{
  struct tm *tm = localtime (&t);
  printf ("tm_isdst (from main program): %d\n", tm->tm_isdst);
  printf ("daylight (from main program): %d\n", daylight);
}

int
main (void)
{
  setenv ("TZ", "Europe/Berlin", 1);
  void *handle = dlopen ("./mylocaltime-export", RTLD_NOW);
  if (handle == NULL)
    errx (1, "dlopen: %s", dlerror ());
  void *func = dlsym (handle, "mylocaltime");
  if (func == NULL)
    errx (1, "dlsym: %s", dlerror ());
  void (*fptr) (time_t) = func;
  mylocaltime2 (1555332781);
  fptr (1555332781);
}

Running the latter produces on x86-64:

tm_isdst (from main program): 1
daylight (from main program): 1
tm_isdst (from other program): 1
daylight (from other program): 0

Such issues will be extremely difficult to debug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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