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

Re: [PATCH] ld: Use libiberty ISDIGIT in linker test plugin


* Andreas Schwab <schwab@suse.de> [2016-07-20 14:23:24 +0200]:

> Andrew Burgess <andrew.burgess@embecosm.com> writes:
> 
> > -libldtestplug_la_LDFLAGS = -no-undefined -rpath /nowhere
> > +libldtestplug_la_LDFLAGS = -no-undefined -rpath /nowhere -L../libiberty -liberty
> 
> You should use $(LIBIBERTY), libraries should be put on LDADD and a
> DEPENDENCIES nees to be added.

Thank you for your feedback.

I tried adding $(LIBIBERTY) onto a LIBADD rule (I started with LDADD,
but autoreconf gave a warning that I should be using LIBADD over
LDADD), however, at build time I got a warning from (I guess) libtool
saying that linking the shared library libtestplug.la against the
static library ../libiberty/libiberty.a is not portable.

>From the original patch I posted, the revision below, moves the
libiberty -L/-l into a _LIBADD rule, and adds a _DEPENDENCIES onto
$(LIBIBERTY).

If this is still not correct then you might need to give me some more
specific guidance.

Thanks,
Andrew

---

ld: Use libiberty ISDIGIT in linker test plugin

Use libiberty ISDIGIT function istead of the standard c-library isdigit
function when building the linker test plugin.

ld/ChangeLog:

	* Makefile.am (libldtestplug_la_LIBADD): Add libibery library.
	(libldtestplug_la_DEPENDENCIES): Add libibery dependency.
	* Makefile.in: Regenerate.
	* testplug.c: Use 'safe-ctype.h' not 'ctype.h'.
	(record_read_length): Use ISDIGIT instead of isdigit.
---
 ld/ChangeLog   | 8 ++++++++
 ld/Makefile.am | 2 ++
 ld/Makefile.in | 4 +++-
 ld/testplug.c  | 4 ++--
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ld/Makefile.am b/ld/Makefile.am
index 16d95bc..24cecfe 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -2148,6 +2148,8 @@ noinst_LTLIBRARIES = libldtestplug.la libldtestplug2.la \
 libldtestplug_la_SOURCES = testplug.c
 libldtestplug_la_CFLAGS= -g -O2
 libldtestplug_la_LDFLAGS = -no-undefined -rpath /nowhere
+libldtestplug_la_LIBADD = -L../libiberty -liberty
+libldtestplug_la_DEPENDENCIES = $(LIBIBERTY)
 libldtestplug2_la_SOURCES = testplug2.c
 libldtestplug2_la_CFLAGS= -g -O2
 libldtestplug2_la_LDFLAGS = -no-undefined -rpath /nowhere
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 1ce019a..657b2c6 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -71,6 +71,7 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 bin_PROGRAMS = ld-new$(EXEEXT)
+@ENABLE_PLUGINS_FALSE@libldtestplug_la_DEPENDENCIES =
 
 # Automake 1.9 will only build info files in the objdir if they are
 # mentioned in DISTCLEANFILES.  It doesn't have to be unconditional,
@@ -109,7 +110,6 @@ CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES = po/Makefile.in
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
-libldtestplug_la_LIBADD =
 @ENABLE_PLUGINS_TRUE@am_libldtestplug_la_OBJECTS =  \
 @ENABLE_PLUGINS_TRUE@	libldtestplug_la-testplug.lo
 libldtestplug_la_OBJECTS = $(am_libldtestplug_la_OBJECTS)
@@ -986,6 +986,8 @@ ld_new_LDADD = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) $(BFDLIB) $(LIBIBERTY) $
 @ENABLE_PLUGINS_TRUE@libldtestplug_la_SOURCES = testplug.c
 @ENABLE_PLUGINS_TRUE@libldtestplug_la_CFLAGS = -g -O2
 @ENABLE_PLUGINS_TRUE@libldtestplug_la_LDFLAGS = -no-undefined -rpath /nowhere
+@ENABLE_PLUGINS_TRUE@libldtestplug_la_LIBADD = -L../libiberty -liberty
+@ENABLE_PLUGINS_TRUE@libldtestplug_la_DEPENDENCIES = $(LIBIBERTY)
 @ENABLE_PLUGINS_TRUE@libldtestplug2_la_SOURCES = testplug2.c
 @ENABLE_PLUGINS_TRUE@libldtestplug2_la_CFLAGS = -g -O2
 @ENABLE_PLUGINS_TRUE@libldtestplug2_la_LDFLAGS = -no-undefined -rpath /nowhere
diff --git a/ld/testplug.c b/ld/testplug.c
index 684fc41..db30ec3 100644
--- a/ld/testplug.c
+++ b/ld/testplug.c
@@ -24,7 +24,7 @@
 /* For ARRAY_SIZE macro only - we don't link the library itself.  */
 #include "libiberty.h"
 
-#include <ctype.h> /* For isdigit.  */
+#include "safe-ctype.h" /* For ISDIGIT.  */
 
 extern enum ld_plugin_status onload (struct ld_plugin_tv *tv);
 static enum ld_plugin_status onclaim_file (const struct ld_plugin_input_file *file,
@@ -172,7 +172,7 @@ record_read_length (const char *length)
   const char *tmp;
 
   tmp = length;
-  while (*tmp != '\0' && isdigit (*tmp))
+  while (*tmp != '\0' && ISDIGIT (*tmp))
     ++tmp;
   if (*tmp != '\0' || *length == '\0')
     {
-- 
2.5.1


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