busybox: Use UTMPX instead of legacy UTMP
PATCH 1/2 busybox: Use UTMPX instead of legacy UTMP
This makes busybox honor UTMPX feature if available in a libc
[YOCTO #8243]
--- .../busybox/0001-Switch-to-POSIX-utmpx-API.patch | 388 +++++++++++++++++++++ meta/recipes-core/busybox/busybox_1.23.2.bb | 1 + 2 files changed, 389 insertions(+) create mode 100644 meta/recipes-core/busybox/busybox/0001-Switch-to-POSIX-utmpx-API.patch
meta/recipes-core/busybox/busybox/0001-Switch-to-POSIX-utmpx-API.patch new file +388 -0
@@ -0,0 +1,388 @@ +From 86a7f18f211af1abda5c855d2674b0fcb53de524 Mon Sep 17 00:00:00 2001 +From: Bernhard Reutner-Fischer <[email protected]> +Date: Thu, 2 Apr 2015 23:03:46 +0200 +Subject: [PATCH] *: Switch to POSIX utmpx API + +UTMP is SVID legacy, UTMPX is mandated by POSIX. + +Glibc and uClibc have identical layout of UTMP and UTMPX, both of these +libc treat _PATH_UTMPX as _PATH_UTMP so from a user-perspective nothing +changes except the names of the API entrypoints. + +Signed-off-by: Bernhard Reutner-Fischer <[email protected]> +--- +Upstream-Status: Backport + + coreutils/who.c | 8 ++++---- + include/libbb.h | 2 +- + init/halt.c | 4 ++-- + libbb/utmp.c | 44 ++++++++++++++++++++++---------------------- + miscutils/last.c | 8 ++++---- + miscutils/last_fancy.c | 16 ++++++++++------ + miscutils/runlevel.c | 12 ++++++------ + miscutils/wall.c | 8 ++++---- + procps/uptime.c | 6 +++--- + 9 files changed, 56 insertions(+), 52 deletions(-) + +diff --git a/coreutils/who.c b/coreutils/who.c +index f955ce6..8337212 100644 +--- a/coreutils/who.c ++++ b/coreutils/who.c +@@ -73,7 +73,7 @@ static void idle_string(char *str6, time_t t) + int who_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int who_main(int argc UNUSED_PARAM, char **argv) + { +- struct utmp *ut; ++ struct utmpx *ut; + unsigned opt; + int do_users = (ENABLE_USERS && (!ENABLE_WHO || applet_name[0] == 'u')); + const char *fmt = "%s"; +@@ -83,8 +83,8 @@ int who_main(int argc UNUSED_PARAM, char **argv) + if (opt & 2) // -H + printf("USER\t\tTTY\t\tIDLE\tTIME\t\t HOST\n"); + +- setutent(); +- while ((ut = getutent()) != NULL) { ++ setutxent(); ++ while ((ut = getutxent()) != NULL) { + if (ut->ut_user[0] + && ((opt & 1) || ut->ut_type == USER_PROCESS) + ) { +@@ -126,6 +126,6 @@ int who_main(int argc UNUSED_PARAM, char **argv) + if (do_users) + bb_putchar('\n'); + if (ENABLE_FEATURE_CLEAN_UP) +- endutent(); ++ endutxent(); + return EXIT_SUCCESS; + } +diff --git a/include/libbb.h b/include/libbb.h +index 26b6868..0f8363b 100644 +--- a/include/libbb.h ++++ b/include/libbb.h +@@ -84,7 +84,7 @@ + # include <selinux/av_permissions.h> + #endif + #if ENABLE_FEATURE_UTMP +-# include <utmp.h> ++# include <utmpx.h> + #endif + #if ENABLE_LOCALE_SUPPORT + # include <locale.h> +diff --git a/init/halt.c b/init/halt.c +index 7974adb..ad12d91 100644 +--- a/init/halt.c ++++ b/init/halt.c +@@ -74,7 +74,7 @@ + + static void write_wtmp(void) + { +- struct utmp utmp; ++ struct utmpx utmp; + struct utsname uts; + /* "man utmp" says wtmp file should *not* be created automagically */ + /*if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) { +@@ -88,7 +88,7 @@ static void write_wtmp(void) + utmp.ut_line[0] = '~'; utmp.ut_line[1] = '~'; /* = strcpy(utmp.ut_line, "~~"); */ + uname(&uts); + safe_strncpy(utmp.ut_host, uts.release, sizeof(utmp.ut_host)); +- updwtmp(bb_path_wtmp_file, &utmp); ++ updwtmpx(bb_path_wtmp_file, &utmp); + } + #else + #define write_wtmp() ((void)0) +diff --git a/libbb/utmp.c b/libbb/utmp.c +index 8ad9ba2..bd07670 100644 +--- a/libbb/utmp.c ++++ b/libbb/utmp.c +@@ -16,7 +16,7 @@ static void touch(const char *filename) + + void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) + { +- struct utmp utent; ++ struct utmpx utent; + char *id; + unsigned width; + +@@ -45,17 +45,17 @@ void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, con + tty_name += 3; + strncpy(id, tty_name, width); + +- touch(_PATH_UTMP); +- //utmpname(_PATH_UTMP); +- setutent(); ++ touch(_PATH_UTMPX); ++ //utmpxname(_PATH_UTMPX); ++ setutxent(); + /* Append new one (hopefully, unless we collide on ut_id) */ +- pututline(&utent); +- endutent(); ++ pututxline(&utent); ++ endutxent(); + + #if ENABLE_FEATURE_WTMP + /* "man utmp" says wtmp file should *not* be created automagically */ + /*touch(bb_path_wtmp_file);*/ +- updwtmp(bb_path_wtmp_file, &utent); ++ updwtmpx(bb_path_wtmp_file, &utent); + #endif + } + +@@ -64,17 +64,17 @@ void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, con + */ + void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) + { +- struct utmp utent; +- struct utmp *utp; ++ struct utmpx utent; ++ struct utmpx *utp; + +- touch(_PATH_UTMP); +- //utmpname(_PATH_UTMP); +- setutent(); ++ touch(_PATH_UTMPX); ++ //utmpxname(_PATH_UTMPX); ++ setutxent(); + + /* Did init/getty/telnetd/sshd/... create an entry for us? + * It should be (new_type-1), but we'd also reuse + * any other potentially stale xxx_PROCESS entry */ +- while ((utp = getutent()) != NULL) { ++ while ((utp = getutxent()) != NULL) { + if (utp->ut_pid == pid + // && ut->ut_line[0] + && utp->ut_id[0] /* must have nonzero id */ +@@ -88,25 +88,25 @@ void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const + /* Stale record. Nuke hostname */ + memset(utp->ut_host, 0, sizeof(utp->ut_host)); + } +- /* NB: pututline (see later) searches for matching utent +- * using getutid(utent) - we must not change ut_id ++ /* NB: pututxline (see later) searches for matching utxent ++ * using getutxid(utent) - we must not change ut_id + * if we want *exactly this* record to be overwritten! + */ + break; + } + } +- //endutent(); - no need, pututline can deal with (and actually likes) ++ //endutxent(); - no need, pututxline can deal with (and actually likes) + //the situation when utmp file is positioned on found record + + if (!utp) { + if (new_type != DEAD_PROCESS) + write_new_utmp(pid, new_type, tty_name, username, hostname); + else +- endutent(); ++ endutxent(); + return; + } + +- /* Make a copy. We can't use *utp, pututline's internal getutid ++ /* Make a copy. We can't use *utp, pututxline's internal getutxid + * will overwrite it before it is used! */ + utent = *utp; + +@@ -120,14 +120,14 @@ void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const + utent.ut_tv.tv_sec = time(NULL); + + /* Update, or append new one */ +- //setutent(); +- pututline(&utent); +- endutent(); ++ //setutxent(); ++ pututxline(&utent); ++ endutxent(); + + #if ENABLE_FEATURE_WTMP + /* "man utmp" says wtmp file should *not* be created automagically */ + /*touch(bb_path_wtmp_file);*/ +- updwtmp(bb_path_wtmp_file, &utent); ++ updwtmpx(bb_path_wtmp_file, &utent); + #endif + } + +diff --git a/miscutils/last.c b/miscutils/last.c +index a144c7e..6d8b584 100644 +--- a/miscutils/last.c ++++ b/miscutils/last.c +@@ -32,21 +32,21 @@ + + #if defined UT_LINESIZE \ + && ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256)) +-#error struct utmp member char[] size(s) have changed! ++#error struct utmpx member char[] size(s) have changed! + #elif defined __UT_LINESIZE \ + && ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 64) || (__UT_HOSTSIZE != 256)) +-#error struct utmp member char[] size(s) have changed! ++#error struct utmpx member char[] size(s) have changed! + #endif + + #if EMPTY != 0 || RUN_LVL != 1 || BOOT_TIME != 2 || NEW_TIME != 3 || \ + OLD_TIME != 4 +-#error Values for the ut_type field of struct utmp changed ++#error Values for the ut_type field of struct utmpx changed + #endif + + int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) + { +- struct utmp ut; ++ struct utmpx ut; + int n, file = STDIN_FILENO; + time_t t_tmp; + off_t pos; +diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c +index 16ed9e9..8194e31 100644 +--- a/miscutils/last_fancy.c ++++ b/miscutils/last_fancy.c +@@ -22,6 +22,10 @@ + #define HEADER_LINE_WIDE "USER", "TTY", \ + INET6_ADDRSTRLEN, INET6_ADDRSTRLEN, "HOST", "LOGIN", " TIME", "" + ++#if !defined __UT_LINESIZE && defined UT_LINESIZE ++# define __UT_LINESIZE UT_LINESIZE ++#endif ++ + enum { + NORMAL, + LOGGED, +@@ -39,7 +43,7 @@ enum { + + #define show_wide (option_mask32 & LAST_OPT_W) + +-static void show_entry(struct utmp *ut, int state, time_t dur_secs) ++static void show_entry(struct utmpx *ut, int state, time_t dur_secs) + { + unsigned days, hours, mins; + char duration[sizeof("(%u+02:02)") + sizeof(int)*3]; +@@ -104,7 +108,7 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) + duration_str); + } + +-static int get_ut_type(struct utmp *ut) ++static int get_ut_type(struct utmpx *ut) + { + if (ut->ut_line[0] == '~') { + if (strcmp(ut->ut_user, "shutdown") == 0) { +@@ -142,7 +146,7 @@ static int get_ut_type(struct utmp *ut) + return ut->ut_type; + } + +-static int is_runlevel_shutdown(struct utmp *ut) ++static int is_runlevel_shutdown(struct utmpx *ut) + { + if (((ut->ut_pid & 255) == '0') || ((ut->ut_pid & 255) == '6')) { + return 1; +@@ -154,7 +158,7 @@ static int is_runlevel_shutdown(struct utmp *ut) + int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int last_main(int argc UNUSED_PARAM, char **argv) + { +- struct utmp ut; ++ struct utmpx ut; + const char *filename = _PATH_WTMP; + llist_t *zlist; + off_t pos; +@@ -242,9 +246,9 @@ int last_main(int argc UNUSED_PARAM, char **argv) + { + llist_t *el, *next; + for (el = zlist; el; el = next) { +- struct utmp *up = (struct utmp *)el->data; ++ struct utmpx *up = (struct utmpx *)el->data; + next = el->link; +- if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) { ++ if (strncmp(up->ut_line, ut.ut_line, __UT_LINESIZE) == 0) { + if (show) { + show_entry(&ut, NORMAL, up->ut_tv.tv_sec); + show = 0; +diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c +index 76231df..8558db8 100644 +--- a/miscutils/runlevel.c ++++ b/miscutils/runlevel.c +@@ -29,19 +29,19 @@ + int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int runlevel_main(int argc UNUSED_PARAM, char **argv) + { +- struct utmp *ut; ++ struct utmpx *ut; + char prev; + +- if (argv[1]) utmpname(argv[1]); ++ if (argv[1]) utmpxname(argv[1]); + +- setutent(); +- while ((ut = getutent()) != NULL) { ++ setutxent(); ++ while ((ut = getutxent()) != NULL) { + if (ut->ut_type == RUN_LVL) { + prev = ut->ut_pid / 256; + if (prev == 0) prev = 'N'; + printf("%c %c\n", prev, ut->ut_pid % 256); + if (ENABLE_FEATURE_CLEAN_UP) +- endutent(); ++ endutxent(); + return 0; + } + } +@@ -49,6 +49,6 @@ int runlevel_main(int argc UNUSED_PARAM, char **argv) + puts("unknown"); + + if (ENABLE_FEATURE_CLEAN_UP) +- endutent(); ++ endutxent(); + return 1; + } +diff --git a/miscutils/wall.c b/miscutils/wall.c +index bb709ee..50658f4 100644 +--- a/miscutils/wall.c ++++ b/miscutils/wall.c +@@ -32,7 +32,7 @@ + int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int wall_main(int argc UNUSED_PARAM, char **argv) + { +- struct utmp *ut; ++ struct utmpx *ut; + char *msg; + int fd; + +@@ -46,8 +46,8 @@ int wall_main(int argc UNUSED_PARAM, char **argv) + msg = xmalloc_read(fd, NULL); + if (ENABLE_FEATURE_CLEAN_UP && argv[1]) + close(fd); +- setutent(); +- while ((ut = getutent()) != NULL) { ++ setutxent(); ++ while ((ut = getutxent()) != NULL) { + char *line; + if (ut->ut_type != USER_PROCESS) + continue; +@@ -56,7 +56,7 @@ int wall_main(int argc UNUSED_PARAM, char **argv) + free(line); + } + if (ENABLE_FEATURE_CLEAN_UP) { +- endutent(); ++ endutxent(); + free(msg); + } + return EXIT_SUCCESS; +diff --git a/procps/uptime.c b/procps/uptime.c +index 778812a..149bae6 100644 +--- a/procps/uptime.c ++++ b/procps/uptime.c +@@ -81,10 +81,10 @@ int uptime_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) + + #if ENABLE_FEATURE_UPTIME_UTMP_SUPPORT + { +- struct utmp *ut; ++ struct utmpx *ut; + unsigned users = 0; +- while ((ut = getutent()) != NULL) { +- if ((ut->ut_type == USER_PROCESS) && (ut->ut_name[0] != '\0')) ++ while ((ut = getutxent()) != NULL) { ++ if ((ut->ut_type == USER_PROCESS) && (ut->ut_user[0] != '\0')) + users++; + } + printf(", %u users", users); +-- +2.5.1 +
meta/recipes-core/busybox/busybox_1.23.2.bb +1 -0
@@ -30,6 +30,7 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://login-utilities.cfg \ file://recognize_connmand.patch \ file://busybox-cross-menuconfig.patch \ + file://0001-Switch-to-POSIX-utmpx-API.patch \ file://0001-ifconfig-fix-double-free-fatal-error-in-INET_sprint.patch \ file://0001-chown-fix-help-text.patch \ file://mount-via-label.cfg \
Signature · 1 line
2.5.3
PATCH 2/2 busybox: Use CC instead of bare LD to be the Linker
This patch was on mailing list, another patch to make sure -r is not passed directly but via -Wl switch is added.
This was exposed when using clang and gold linker, clang does not have -r switch to do relocatable objects and problem happens specific to OE becuase we use LD = CC
now what happens is that busybox assumes that linker will be called directly, and hence sprinkles linkers options in its kbuild system which aggregate into LDFLAGS, some of these options are happily ignored by gcc as well but it passes -r options rightly to linker so it all works, however when using clang, this falls apart since -r is not known option for clang so it drops this option and all obects which should be partially linked becomes ET_EXEC and when they are added to final link then gold starts to get confused
/mnt/home/kraj/work/angstrom/build/tmp-angstrom-glibc/sysroots/x86_64-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-ld:
error: applets/built-in.o: unsupported ELF file type 2
clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation)
--- ...-linking-instead-of-LD-and-use-CFLAGS-and.patch | 114 +++++++++++++++++++++ .../busybox/0002-Passthrough-r-to-linker.patch | 32 ++++++ meta/recipes-core/busybox/busybox_1.23.2.bb | 2 + 3 files changed, 148 insertions(+) create mode 100644 meta/recipes-core/busybox/busybox/0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch create mode 100644 meta/recipes-core/busybox/busybox/0002-Passthrough-r-to-linker.patch
meta/recipes-core/busybox/busybox/0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch new file +114 -0
@@ -0,0 +1,114 @@ +From a9333eb6a7b8dbda735947cd5bc981ff9352a2c9 Mon Sep 17 00:00:00 2001 +From: Nathan Phillip Brink <[email protected]> +Date: Thu, 10 Mar 2011 00:27:08 -0500 +Subject: [PATCH 1/2] Use $(CC) when linking instead of $(LD) and use $(CFLAGS) + and $(EXTRA_CFLAGS) when linking. + +This fixes the issue where LDFLAGS escaped with -Wl are ignored during +compilation. It also simplifies using CFLAGS or EXTRA_CFLAGS (such as +-m32 on x86_64 or -flto) which apply to both compilation and linking +situations. + +Signed-off-by: Nathan Phillip Brink <[email protected]> +--- +Upstream-Status: Pending + + Makefile | 7 ++++--- + scripts/Makefile.build | 8 ++++---- + scripts/Makefile.lib | 13 +++---------- + 3 files changed, 11 insertions(+), 17 deletions(-) + +Index: busybox-1.23.2/Makefile +=================================================================== +--- busybox-1.23.2.orig/Makefile ++++ busybox-1.23.2/Makefile +@@ -309,7 +309,8 @@ CHECKFLAGS := -D__linux__ -Dlinux -D + MODFLAGS = -DMODULE + CFLAGS_MODULE = $(MODFLAGS) + AFLAGS_MODULE = $(MODFLAGS) +-LDFLAGS_MODULE = -r ++LDFLAGS_RELOCATABLE = -r -nostdlib ++LDFLAGS_MODULE = $(LDFLAGS_RELOCATABLE) + CFLAGS_KERNEL = + AFLAGS_KERNEL = + +@@ -331,7 +332,7 @@ KERNELVERSION = $(VERSION).$(PATCHLEVEL) + export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \ + ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ + CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ +- HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS ++ HOSTCXX HOSTCXXFLAGS LDFLAGS_RELOCATABLE LDFLAGS_MODULE CHECK CHECKFLAGS + + export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS + export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE +@@ -610,7 +611,7 @@ quiet_cmd_busybox__ ?= LINK $@ + cmd_busybox__ ?= $(srctree)/scripts/trylink \ + "$@" \ + "$(CC)" \ +- "$(CFLAGS) $(CFLAGS_busybox)" \ ++ "$(CFLAGS) $(CFLAGS_busybox) $(EXTRA_CFLAGS)" \ + "$(LDFLAGS) $(EXTRA_LDFLAGS)" \ + "$(core-y)" \ + "$(libs-y)" \ +Index: busybox-1.23.2/scripts/Makefile.build +=================================================================== +--- busybox-1.23.2.orig/scripts/Makefile.build ++++ busybox-1.23.2/scripts/Makefile.build +@@ -174,7 +174,7 @@ cmd_modversions = \ + | $(GENKSYMS) -a $(ARCH) \ + > $(@D)/.tmp_$(@F:.o=.ver); \ + \ +- $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ ++ $(CC) $(ld_flags_partial) $(LDFLAGS_RELOCATABLE) -o $@ $(@D)/.tmp_$(@F) \ + -T $(@D)/.tmp_$(@F:.o=.ver); \ + rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ + else \ +@@ -257,7 +257,7 @@ quiet_cmd_link_o_target = LD $@ + # If the list of objects to link is empty, just create an empty built-in.o + # -nostdlib is added to make "make LD=gcc ..." work (some people use that) + cmd_link_o_target = $(if $(strip $(obj-y)),\ +- $(LD) -nostdlib $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ ++ $(CC) $(ld_flags_partial) $(LDFLAGS_RELOCATABLE) -o $@ $(filter $(obj-y), $^),\ + rm -f $@; $(AR) rcs $@) + + $(builtin-target): $(obj-y) FORCE +@@ -292,10 +292,10 @@ $($(subst $(obj)/,,$(@:.o=-objs))) \ + $($(subst $(obj)/,,$(@:.o=-y)))), $^) + + quiet_cmd_link_multi-y = LD $@ +-cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) ++cmd_link_multi-y = $(CC) $(ld_flags_partial) $(LDFLAGS_RELOCATABLE) -o $@ $(link_multi_deps) + + quiet_cmd_link_multi-m = LD [M] $@ +-cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps) ++cmd_link_multi-m = $(CC) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps) + + # We would rather have a list of rules like + # foo.o: $(foo-objs) +Index: busybox-1.23.2/scripts/Makefile.lib +=================================================================== +--- busybox-1.23.2.orig/scripts/Makefile.lib ++++ busybox-1.23.2/scripts/Makefile.lib +@@ -121,7 +121,8 @@ cpp_flags = -Wp,-MD,$(depfile) $(NO + # yet ld_flags is fed to ld. + #ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS) + # Remove the -Wl, prefix from linker options normally passed through gcc +-ld_flags = $(filter-out -Wl$(comma)%,$(LDFLAGS) $(EXTRA_LDFLAGS)) ++ld_flags = $(filter-out -Wl$(comma)%,$(LDFLAGS) $(EXTRA_LDFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)) ++ld_flags_partial = $($(filter-out -shared%, $(filter-out -pie%,$(ld_flags)))) + + + # Finds the multi-part object the current object will be linked into +@@ -151,10 +152,8 @@ $(obj)/%:: $(src)/%_shipped + # Linking + # --------------------------------------------------------------------------- + +-# TODO: LDFLAGS usually is supposed to contain gcc's flags, not ld's. +-# but here we feed them to ld! +-quiet_cmd_ld = LD $@ +-cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \ ++quiet_cmd_ld = CC $@ ++cmd_ld = $(CC) $(ld_flags) $(LDFLAGS_$(@F)) \ + $(filter-out FORCE,$^) -o $@ + + # Objcopy
meta/recipes-core/busybox/busybox/0002-Passthrough-r-to-linker.patch new file +32 -0
@@ -0,0 +1,32 @@ +From df2cc76cdebc4773361477f3db203790f6986e3b Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sat, 22 Aug 2015 23:42:40 -0700 +Subject: [PATCH 2/2] Passthrough -r to linker + +clang does not have -r switch and it does not pass it down to linker +either, LDFLAGS_RELOCATABLE is used when CC is used for LD, so this +should not cause side effects + +Signed-off-by: Khem Raj <[email protected]> +--- +Upstream-Status: Pending + + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 9da02cb..10dd4a9 100644 +--- a/Makefile ++++ b/Makefile +@@ -309,7 +309,7 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(C + MODFLAGS = -DMODULE + CFLAGS_MODULE = $(MODFLAGS) + AFLAGS_MODULE = $(MODFLAGS) +-LDFLAGS_RELOCATABLE = -r -nostdlib ++LDFLAGS_RELOCATABLE = -Xlinker -r -nostdlib + LDFLAGS_MODULE = $(LDFLAGS_RELOCATABLE) + CFLAGS_KERNEL = + AFLAGS_KERNEL = +-- +2.1.4 +
meta/recipes-core/busybox/busybox_1.23.2.bb +2 -0
@@ -33,6 +33,8 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://0001-Switch-to-POSIX-utmpx-API.patch \ file://0001-ifconfig-fix-double-free-fatal-error-in-INET_sprint.patch \ file://0001-chown-fix-help-text.patch \ + file://0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch \ + file://0002-Passthrough-r-to-linker.patch \ file://mount-via-label.cfg \ file://sha1sum.cfg \ file://sha256sum.cfg \
Signature · 1 line
2.5.3