2013-06-06 01:53:30 +02:00
|
|
|
################################################################################
|
2006-12-12 23:16:41 +01:00
|
|
|
#
|
|
|
|
# dmalloc
|
|
|
|
#
|
2013-06-06 01:53:30 +02:00
|
|
|
################################################################################
|
2013-01-20 10:45:47 +01:00
|
|
|
|
2021-11-24 18:29:13 +01:00
|
|
|
DMALLOC_VERSION = 5.6.5
|
2013-01-20 10:45:47 +01:00
|
|
|
DMALLOC_SOURCE = dmalloc-$(DMALLOC_VERSION).tgz
|
|
|
|
DMALLOC_SITE = http://dmalloc.com/releases
|
2006-12-12 23:16:41 +01:00
|
|
|
|
2021-11-24 18:29:13 +01:00
|
|
|
DMALLOC_LICENSE = ISC
|
|
|
|
DMALLOC_LICENSE_FILES = LICENSE.txt
|
2012-11-13 02:05:39 +01:00
|
|
|
|
2010-06-16 13:47:04 +02:00
|
|
|
DMALLOC_INSTALL_STAGING = YES
|
2015-01-20 12:24:37 +01:00
|
|
|
DMALLOC_CFLAGS = $(TARGET_CFLAGS)
|
2007-01-20 21:54:05 +01:00
|
|
|
|
package/dmalloc: don't use SSP
dmalloc directly calls into $(LD) to generate a shared library our of
the static one.
To detect what command it should run, ./configure tries various
incantations of ld with various command line options until one does not
fail. One of those is (basically):
$(LD) --whole-archive -o contest.o.t contest.a
This makes ./configure conclude what the command to link a shared
library in the Makefile should be, and thus stores that in a variable:
shlinkargs='$(LD) --whole-archive -o $@'
... which is then AC_SUBST()ed into Makefile.in with a rule like:
$(SHLIB): $(LIBRARY)
@shlinkargs@ $(LIRARY)
which once substiuted, gives:
$(SHLIB): $(LIBRARY)
$(LD) --whole-archive -o $@ $(LIRARY)
However, when SSP is enabled, the __stack_chk_fail_local and co symbols
are provided by additional libraries or object files, and that is the
responsibility of gcc to pass those when linking. But as dmalloc
directly calls ld, it misses those.
Changing dmalloc to use $(CC) is not trivial, however.
First, we can't pass LD=$(TARGET_CC), otherwise the whole package
explodes [0]: indeed --whole-archive is unknown to gcc, so it must be
passed as -Wl,--whole archive instead. So we'd need to add a new test
that uses $(CC), like so:
$(CC) -Wl,--whole-archive -o contest.o.t contest.a
However, in that case, gcc does pass additional libs/objs (like, for
eample, the SSP ones) to the linker. But then those are also included
in the whole-archive section. This causes the linker to add all the
symbols form those libs/objs, even those not needed for SSP; on some
archs, like PPC, that may require floating point symbols (__muldiv3 et
al.) which are in another library, and thus the linker can't find them.
The proper solution wouild be to add -Wl,--no-whole-archive, but that
would have to be added _after_ the library we want to link, i.e.e we
should be able to evntually run:
$(CC) -Wl,--whole-archive -o $@ $(LIRARY) -Wl,--no-whole-archive
That would require that we introduce a new variable that is added
_after_ the $(LIBRARY), e.g. @shlinkargs_post@ or so...
This is a bigger endeavour than we want to pursue...
Since dmalloc is a debugging utility, it is not supposed to go into
production builds, and during debugging, it would not be surprising that
it needs to poke around arrays to debug them.
So, we go the easier route: disable SSP altogether.
[0] with lots of nice colors, but that's not the point, is it?
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-02-08 20:31:35 +01:00
|
|
|
# dmalloc uses $(LD) to link, and thus misses the object files or libs that
|
|
|
|
# are needed to provide the __stack_chk_fail_local and co. symbols. Changing
|
|
|
|
# to use $(CC) is really more complex that we'd like. Since dmalloc is
|
|
|
|
# involved in debugging memory allocation, it is not expected to be a
|
|
|
|
# production library, so we do not care that much that it has SSP.
|
|
|
|
DMALLOC_CFLAGS += -fno-stack-protector
|
|
|
|
|
2021-05-15 17:17:30 +02:00
|
|
|
ifeq ($(BR2_STATIC_LIBS),y)
|
|
|
|
DMALLOC_CONF_OPTS += --disable-shlib
|
|
|
|
else
|
|
|
|
DMALLOC_CONF_OPTS += --enable-shlib
|
2021-04-17 12:49:19 +02:00
|
|
|
DMALLOC_CFLAGS += -fPIC
|
|
|
|
endif
|
|
|
|
|
2007-01-20 21:54:05 +01:00
|
|
|
ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
|
2014-09-27 21:32:44 +02:00
|
|
|
DMALLOC_CONF_OPTS += --enable-cxx
|
2007-01-20 21:54:05 +01:00
|
|
|
else
|
2014-09-27 21:32:44 +02:00
|
|
|
DMALLOC_CONF_OPTS += --disable-cxx
|
2007-01-20 21:54:05 +01:00
|
|
|
endif
|
|
|
|
|
2010-12-13 17:27:44 +01:00
|
|
|
ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
|
2014-09-27 21:32:44 +02:00
|
|
|
DMALLOC_CONF_OPTS += --enable-threads
|
2010-12-13 17:27:44 +01:00
|
|
|
else
|
2014-09-27 21:32:44 +02:00
|
|
|
DMALLOC_CONF_OPTS += --disable-threads
|
2007-01-20 21:54:05 +01:00
|
|
|
endif
|
|
|
|
|
2015-01-20 12:24:37 +01:00
|
|
|
# dmalloc has some assembly function that are not present in thumb1 mode:
|
|
|
|
# Error: lo register required -- `str lr,[sp,#4]'
|
|
|
|
# so, we desactivate thumb mode
|
|
|
|
ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
|
|
|
|
DMALLOC_CFLAGS += -marm
|
|
|
|
endif
|
|
|
|
|
2019-06-14 23:03:39 +02:00
|
|
|
ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_63261),y)
|
|
|
|
DMALLOC_CFLAGS += -O0
|
|
|
|
endif
|
|
|
|
|
package/dmalloc: use actual patches rather than sed-ing
Our dmalloc packaging is very old and carries historical baggage and
idiosyncracies that we have long stopped doing in the rest ofthe code
base.
Drop our post-patch hooks that seds the configure and Makefile.in files,
and add patches (that could be upstreamed one day).
We provide the results in the environment, like would be done with
actual autoconf cache variables (ac_cv_*).
Note: those are the result of cleaning up for further patches that did
not manifest because it was too complex to add proper SSP support to
dmalloc (instead, we're going to forcibly disable it in the following
commit).
Note-2: those patches have not been submitted upstream, as it's mostly
dead: even though there's been some commit activities recently-ish, there
has been no review or comments or the many PR pending for many years
now.
Note-3: we patch both configure and configure.ac, rather than
autoreconf, for two reasons: 1. the both are in the upstream git tree,
so submitting these patches would require patching both, and 2. dmalloc
does not autoreconf nicely out of the box, and it was deemed too much
hassle to fix that in addition.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-02-08 20:31:34 +01:00
|
|
|
DMALLOC_CONF_ENV = \
|
|
|
|
CFLAGS="$(DMALLOC_CFLAGS)" \
|
|
|
|
ac_cv_page_size=12 \
|
|
|
|
ac_cv_strdup_macro=yes \
|
|
|
|
ac_cv_strndup_macro=yes
|
2006-12-12 23:16:41 +01:00
|
|
|
|
2010-06-16 13:47:04 +02:00
|
|
|
# both DESTDIR and PREFIX are ignored..
|
|
|
|
define DMALLOC_INSTALL_STAGING_CMDS
|
2016-10-17 18:06:34 +02:00
|
|
|
$(TARGET_MAKE_ENV) $(MAKE) includedir="$(STAGING_DIR)/usr/include" \
|
2007-01-20 21:54:05 +01:00
|
|
|
bindir="$(STAGING_DIR)/usr/bin" \
|
|
|
|
libdir="$(STAGING_DIR)/usr/lib" \
|
|
|
|
shlibdir="$(STAGING_DIR)/usr/lib" \
|
2011-09-28 16:29:55 +02:00
|
|
|
infodir="$(STAGING_DIR)/usr/share/info/" \
|
2010-06-16 13:47:04 +02:00
|
|
|
-C $(@D) install
|
|
|
|
endef
|
2006-12-12 23:16:41 +01:00
|
|
|
|
2016-06-13 08:07:17 +02:00
|
|
|
ifeq ($(BR2_STATIC_LIBS),)
|
|
|
|
define DMALLOC_INSTALL_SHARED_LIB
|
2013-02-13 16:12:02 +01:00
|
|
|
cp -dpf $(STAGING_DIR)/usr/lib/libdmalloc*.so $(TARGET_DIR)/usr/lib
|
2016-06-13 08:07:17 +02:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
define DMALLOC_INSTALL_TARGET_CMDS
|
|
|
|
$(DMALLOC_INSTALL_SHARED_LIB)
|
2010-06-16 13:47:04 +02:00
|
|
|
cp -dpf $(STAGING_DIR)/usr/bin/dmalloc $(TARGET_DIR)/usr/bin/dmalloc
|
|
|
|
endef
|
2006-12-12 23:16:41 +01:00
|
|
|
|
2012-07-03 00:07:32 +02:00
|
|
|
$(eval $(autotools-package))
|