From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/files/
Date: Mon, 15 Feb 2016 14:30:42 +0000 (UTC) [thread overview]
Message-ID: <1455546637.8cb9c22e827757a7c5151c53afb2b4d4e0a3d0c6.grobian@gentoo> (raw)
commit: 8cb9c22e827757a7c5151c53afb2b4d4e0a3d0c6
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 15 14:30:37 2016 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Feb 15 14:30:37 2016 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=8cb9c22e
sys-devel/binutils-config: position all added arguments after given arguments in ldwrapper
Package-Manager: portage-2.2.20-prefix
sys-devel/binutils-config/files/ldwrapper.c | 58 +++++++++++++++++++++--------
1 file changed, 43 insertions(+), 15 deletions(-)
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index 4256e78..958bed4 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -151,6 +151,7 @@ main(int argc, char *argv[])
char *p;
int i;
int j;
+ int k;
/* cannonicanise wrapper, stripping path and CHOST */
if ((p = strrchr(wrapper, '/')) != NULL) {
@@ -207,36 +208,63 @@ main(int argc, char *argv[])
/* inject this first to make the intention clear */
newargv[j++] = "-search_paths_first";
#endif
+ /* position k right after the original arguments */
+ k = j - 1 + argc;
for (i = 1; i < argc; i++, j++) {
newargv[j] = argv[i];
#ifndef TARGET_DARWIN
/* on ELF targets we add runpaths for all found search paths */
- if (argv[i][0] == '-' && argv[i][1] == 'L' && argv[i][2] == '/') {
- newargv[++j] = strdup(argv[i]);
- if (newargv[j] == NULL) {
+ if (argv[i][0] == '-' && argv[i][1] == 'L') {
+ char *path;
+ size_t len;
+
+ /* arguments can be in many ways here:
+ * -L<path>
+ * -L <path> (yes, this is accepted)
+ * -L(whitespace)? <path in next argument>
+ * where path is absolute (not relative) */
+ path = &argv[i][2];
+ while (*path != '\0' && isspace(*path))
+ path++;
+ if (*path == '\0') {
+ /* no more arguments?!? skip */
+ if (i + 1 >= argc)
+ continue;
+ path = argv[i + 1];
+ while (*path != '\0' && isspace(*path))
+ path++;
+ }
+ /* not absolute (or empty)?!? skip */
+ if (*path != '/')
+ continue;
+
+ len = 2 + strlen(path) + 1;
+ newargv[k] = malloc(sizeof(char) * len);
+ if (newargv[k] == NULL) {
fprintf(stderr, "%s: failed to allocate memory for "
"'%s' -R argument\n", wrapper, argv[i]);
exit(1);
}
- newargv[j][1] = 'R';
+ snprintf(newargv[k], len, "-R%s", path);
+ k++;
}
#endif
}
/* add the custom paths */
#ifdef TARGET_DARWIN
- newargv[j++] = "-L" EPREFIX "/usr/lib";
- newargv[j++] = "-L" EPREFIX "/lib";
+ newargv[k++] = "-L" EPREFIX "/usr/lib";
+ newargv[k++] = "-L" EPREFIX "/lib";
#else
- newargv[j++] = "-L" EPREFIX "/usr/" CHOST "/lib/gcc";
- newargv[j++] = "-R" EPREFIX "/usr/" CHOST "/lib/gcc";
- newargv[j++] = "-L" EPREFIX "/usr/" CHOST "/lib";
- newargv[j++] = "-R" EPREFIX "/usr/" CHOST "/lib";
- newargv[j++] = "-L" EPREFIX "/usr/lib";
- newargv[j++] = "-R" EPREFIX "/usr/lib";
- newargv[j++] = "-L" EPREFIX "/lib";
- newargv[j++] = "-R" EPREFIX "/lib";
+ newargv[k++] = "-L" EPREFIX "/usr/" CHOST "/lib/gcc";
+ newargv[k++] = "-R" EPREFIX "/usr/" CHOST "/lib/gcc";
+ newargv[k++] = "-L" EPREFIX "/usr/" CHOST "/lib";
+ newargv[k++] = "-R" EPREFIX "/usr/" CHOST "/lib";
+ newargv[k++] = "-L" EPREFIX "/usr/lib";
+ newargv[k++] = "-R" EPREFIX "/usr/lib";
+ newargv[k++] = "-L" EPREFIX "/lib";
+ newargv[k++] = "-R" EPREFIX "/lib";
#endif
- newargv[j] = NULL;
+ newargv[k] = NULL;
if (verbose) {
fprintf(stdout, "%s: invoking %s with arguments:\n", wrapper, ld);
next reply other threads:[~2016-02-15 14:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 14:30 Fabian Groffen [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-01-13 14:29 [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/files/ Fabian Groffen
2023-09-26 19:38 Fabian Groffen
2020-11-27 13:57 Fabian Groffen
2020-11-27 13:39 Fabian Groffen
2018-01-31 9:50 Fabian Groffen
2017-12-29 14:56 Fabian Groffen
2017-12-27 9:05 Fabian Groffen
2017-12-25 19:47 Fabian Groffen
2017-11-29 15:21 Fabian Groffen
2017-11-25 18:33 Fabian Groffen
2016-05-15 16:44 Fabian Groffen
2016-05-13 12:14 Fabian Groffen
2016-05-13 12:14 Fabian Groffen
2016-05-13 12:14 Fabian Groffen
2016-04-18 8:07 Michael Haubenwallner
2016-02-14 14:56 Fabian Groffen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455546637.8cb9c22e827757a7c5151c53afb2b4d4e0a3d0c6.grobian@gentoo \
--to=grobian@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox