mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] MUSL ignores__attribute__((constructor(priority))) ?
@ 2020-05-21 20:22 Harald Welte
  2020-05-21 20:40 ` Rich Felker
  0 siblings, 1 reply; 9+ messages in thread
From: Harald Welte @ 2020-05-21 20:22 UTC (permalink / raw)
  To: musl

Hi all!

While investigating some really strange behavior of osmocom software
on MUSL based systems (see https://osmocom.org/issues/4456)
there are two observations:

1) if there are multiple libraries (in this example libosmocore and libtalloc,
   where libosmocore depends on libtalloc), the __attribute__((constructor))
   functions are not called in inverse dependency order, i.e. the talloc
   ones are *not* called before those of libosmocore.

2) even when adding an explicit "priority" field like
   static __attribute__((constructor(65535))) void on_dso_load_ctx(void)
   the MUSL ld.so doesnt' seem to respect this, i.e. it still calls the
   constructor with the high priority value *before* the constructor of lower
   priority.  This is not as specified in https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html

I don't know whether '1' is a bug (i.e. whether it is valid to assume constructors
of libraries are executed in-line with library dependencies).   However, I am
quite convinced '2' is a bug.

Regards,
	Harald

p.s.: Please keep me in Cc, I'm not a subscriber to this list.

-- 
- Harald Welte <laforge@gnumonks.org>           http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-22 23:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 20:22 [musl] MUSL ignores__attribute__((constructor(priority))) ? Harald Welte
2020-05-21 20:40 ` Rich Felker
2020-05-21 21:19   ` Harald Welte
2020-05-21 21:49     ` Rich Felker
2020-05-22 16:50       ` Harald Welte
2020-05-22 17:33         ` Rich Felker
2020-05-22 17:45           ` Hauke Mehrtens
2020-05-22 17:53             ` Rich Felker
2020-05-22 23:37               ` Alexander 'lynxis' Couzens

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).