public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: elfutils-devel@sourceware.org
Subject: [PATCH 3/5] Add PIC and non-PIC variants of libcpu and libebl
Date: Sat, 06 Jul 2019 00:35:00 -0000	[thread overview]
Message-ID: <0df77b9f6b5ad217f0ad70ef7ac3f113e78d2adf.1562372641.git.osandov@fb.com> (raw)
In-Reply-To: <cover.1562372641.git.osandov@fb.com>

From: Omar Sandoval <osandov@fb.com>

Currently, libcpu and libebl are always compiled as PIC. An upcoming
change will add the objects from libcpu.a and libebl.a to libdw.a, which
should not be PIC unless configured that way. So, make libcpu.a and
libebl.a non-PIC and add libcpu_pic.a and libebl_pic.a.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 backends/ChangeLog   |  1 +
 backends/Makefile.am |  2 +-
 libcpu/ChangeLog     |  2 ++
 libcpu/Makefile.am   | 18 +++++++++++++-----
 libdw/ChangeLog      |  4 ++++
 libdw/Makefile.am    |  2 +-
 libebl/ChangeLog     |  4 +++-
 libebl/Makefile.am   |  8 +++++++-
 8 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index 219e0702..d631417f 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,6 +1,7 @@
 2019-07-05  Omar Sandoval  <osandov@fb.com>
 
 	* Makefile.am: Replace libcpu_{i386,x86_64,bpf}.a with libcpu.a.
+	Replace libcpu.a with libcpu_pic.a.
 
 2019-04-14  Mark Wielaard  <mark@klomp.org>
 
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 0307da07..d1275206 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -43,7 +43,7 @@ noinst_LIBRARIES = $(libebl_pic)
 noinst_DATA = $(libebl_pic:_pic.a=.so)
 
 
-libcpu = ../libcpu/libcpu.a
+libcpu = ../libcpu/libcpu_pic.a
 libelf = ../libelf/libelf.so
 libdw = ../libdw/libdw.so
 libeu = ../lib/libeu.a
diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog
index c0ea72ec..883896a2 100644
--- a/libcpu/ChangeLog
+++ b/libcpu/ChangeLog
@@ -1,6 +1,8 @@
 2019-07-05  Omar Sandoval  <osandov@fb.com>
 
 	* Makefile.am: Combine libcpu_{i386,x86_64,bpf}.a into libcpu.a.
+	Make libcpu.a non-PIC by default.
+	Add libcpu_pic.a.
 
 2018-11-04  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index a7d9f6fd..88717361 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -30,15 +30,22 @@
 include $(top_srcdir)/config/eu.am
 AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
 	    -I$(srcdir)/../libdw -I$(srcdir)/../libasm
-AM_CFLAGS += $(fpic_CFLAGS) -fdollars-in-identifiers
+if BUILD_STATIC
+AM_CFLAGS += $(fpic_CFLAGS)
+endif
+AM_CFLAGS += -fdollars-in-identifiers
 LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) -P$(<F:lex.l=)
 LEX_OUTPUT_ROOT = lex.$(<F:lex.l=)
 AM_YFLAGS = -p$(<F:parse.y=)
 
-noinst_LIBRARIES = libcpu.a
+noinst_LIBRARIES = libcpu.a libcpu_pic.a
+
+noinst_HEADERS = i386_dis.h x86_64_dis.h
+
+libcpu_a_SOURCES = i386_disasm.c x86_64_disasm.c bpf_disasm.c
 
-libcpu_a_SOURCES = i386_disasm.c i386_dis.h x86_64_disasm.c x86_64_dis.h \
-		   bpf_disasm.c
+libcpu_pic_a_SOURCES =
+am_libcpu_pic_a_OBJECTS = $(libcpu_a_SOURCES:.c=.os)
 
 i386_gendis_SOURCES = i386_gendis.c i386_lex.l i386_parse.y
 
@@ -50,7 +57,7 @@ x86_64_disasm.o: x86_64.mnemonics $(srcdir)/x86_64_dis.h
 	$(AM_V_at)mv -f $@T $@
 
 if MAINTAINER_MODE
-noinst_HEADERS = memory-access.h i386_parse.h i386_data.h
+noinst_HEADERS += memory-access.h i386_parse.h i386_data.h
 
 noinst_PROGRAMS = i386_gendis$(EXEEXT)
 
@@ -86,5 +93,6 @@ bpf_disasm_CFLAGS = -Wno-format-nonliteral
 
 EXTRA_DIST = defs/i386
 
+MOSTLYCLEANFILES = $(am_libcpu_pic_a_OBJECTS)
 CLEANFILES += $(foreach P,i386 x86_64,$P_defs $P.mnemonics)
 MAINTAINERCLEANFILES = $(foreach P,i386 x86_64, $P_dis.h)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 4760f9de..f9bbeee1 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2019-07-05  Omar Sandoval  <osandov@fb.com>
+
+	* Makefile.am (libdw_so_LIBS): Replace libebl.a with libebl_pic.a.
+
 2019-05-16  Mark Wielaard  <mark@klomp.org>
 
 	* dwarf.h: Add DW_AT_GNU_numerator, DW_AT_GNU_denominator and
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 7a3d5322..7dc4cec0 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -106,7 +106,7 @@ libdw_pic_a_SOURCES =
 am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
 
 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
-	  ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
+	  ../libdwfl/libdwfl_pic.a ../libebl/libebl_pic.a
 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
 libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
 libdw_so_SOURCES =
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 9510f9d5..6fd83471 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,6 +1,8 @@
 2019-07-05  Omar Sandoval  <osandov@fb.com>
 
-	* Makefile.am (gen_SOURCES): Remove.
+	* Makefile.am: Make libebl.a non-PIC by default.
+	Add libebl_pic.a.
+	(gen_SOURCES): Remove.
 
 2019-05-30  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index ccc1a31a..b85ead01 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -28,12 +28,15 @@
 ## not, see <http://www.gnu.org/licenses/>.
 ##
 include $(top_srcdir)/config/eu.am
+if BUILD_STATIC
 AM_CFLAGS += $(fpic_CFLAGS)
+endif
 AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdw -I$(srcdir)/../libasm
 VERSION = 1
 LIBEBL_SUBDIR = @LIBEBL_SUBDIR@
 
 lib_LIBRARIES = libebl.a
+noinst_LIBRARIES = libebl_pic.a
 
 pkginclude_HEADERS = libebl.h
 
@@ -57,6 +60,9 @@ libebl_a_SOURCES = eblopenbackend.c eblclosebackend.c eblreloctypename.c \
 		   eblresolvesym.c eblcheckreloctargettype.c \
 		   ebl_data_marker_symbol.c
 
+libebl_pic_a_SOURCES =
+am_libebl_pic_a_OBJECTS = $(libebl_a_SOURCES:.c=.os)
+
 noinst_HEADERS = libeblP.h ebl-hooks.h
 
-CLEANFILES += $(am_libebl_pic_a_OBJECTS)
+MOSTLYCLEANFILES = $(am_libebl_pic_a_OBJECTS)
-- 
2.22.0

  reply	other threads:[~2019-07-06  0:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-06  0:35 [PATCH 0/5] elfutils: don't use dlopen() for libebl modules Omar Sandoval
2019-07-06  0:35 ` Omar Sandoval [this message]
2019-07-06  0:35 ` [PATCH 5/5] libdw: export libebl symbols Omar Sandoval
2019-07-08 21:14   ` Mark Wielaard
2019-07-06  0:35 ` [PATCH 4/5] Don't use dlopen() for libebl modules Omar Sandoval
2019-07-06  0:35 ` [PATCH 2/5] libcpu: merge libcpu_{i386,x86_64,bpf} into one library Omar Sandoval
2019-07-06  0:35 ` [PATCH 1/5] libebl: remove unnecessary variable in Makefile.am Omar Sandoval

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=0df77b9f6b5ad217f0ad70ef7ac3f113e78d2adf.1562372641.git.osandov@fb.com \
    --to=osandov@osandov.com \
    --cc=elfutils-devel@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).