Skip to contentSkip to conversation

package/libcap: don't overwrite 'empty' when generating loader.txt

PATCH Applied Arnout Vandecappelle (Essensium/Mind) 2 participants 3 messages Aug 23, 2021 – Aug 24, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libcap: don't overwrite 'empty' when generating loader.txt

Upstream commit [1] introduced an invocation of objcopy to generat loader.txt. However, objcopy, if not provided with an output file, will overwrite the input file. This is usually harmless because it will be identical, but the timestamp is updated. This may cause 'empty' to be newer than 'loader.txt', which causes 'loader.txt' and its dependencies to be rebuilt during 'make install'

We provide a different set of parameters during 'make install'. In particular, we no longer pass in HOST_CONFIGURE_OPTS, so we no longer set LDFLAGS. Thus, there is no -Wl,rpath option that is passed in, which causes the resulting binaries to have an incorrect RPATH.

Fix this by adding /dev/null as the output file in the objcopy invocation.

Patch was sent upstream, but there's no mailing list, just a single person.

Fixes: http://autobuild.buildroot.net/results/600/600aff5b839b48db80751cace5fa9670b7a3d698
(hopefully)

[1] https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=efd293947f940180eedd8d0915b124f4aedccc08

---
Note: I tried updating to v1.2.53 first, but that failed due to [2]

[2] https://bugzilla.kernel.org/show_bug.cgi?id=214023#c16

---
 ...don-t-overwrite-empty-when-generatin.patch | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 package/libcap/0001-libcap-Makefile-don-t-overwrite-empty-when-generatin.patch
package/libcap/0001-libcap-Makefile-don-t-overwrite-empty-when-generatin.patch new file +50 -0
new file mode 100644
index 0000000000..a47a2c788e
@@ -0,0 +1,50 @@
+From dc507a812d931c24f1ac98c811fdd29bffa21da9 Mon Sep 17 00:00:00 2001
+From: "Arnout Vandecappelle (Essensium/Mind)" <[email protected]>
+Date: Tue, 24 Aug 2021 00:36:40 +0200
+Subject: [PATCH] libcap/Makefile: don't overwrite 'empty' when generating
+ loader.txt
+
+objcopy takes an input file and an output file as arguments. If the
+output file is left out, the input file will be overwritten.
+
+Since the objcopy command used to generate loader.txt only does a
+dump-section and no filtering, in practice there is no change to empty.
+However, as a side-effect, its timestamp is updated. The timestamp of
+empty and of loader.txt will be more or less the same; however,
+loader.txt is closed just before the output file is closed, so it's
+possible that the timestamp of loader.txt is just a little bit earlier.
+If this happens, it causes loader.txt to be rebuilt later, which in turn
+causes a number of other object files to be rebuilt.
+
+Usually that's harmless, but it sometimes causes the rebuild to happen
+during 'make install'. This is particularly annoying if 'make install'
+is done as root, since loader.txt becomes owned by root in that case.
+
+Fix this by specifying a harmless output file: /dev/null.
+
+While we're at it, take in an upstream change that removes the redundant
+redirect.
+
+Fixes: ee3b25c0a877fa74d1aec88f325ac45b09963c82
+
+Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
+---
+ libcap/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libcap/Makefile b/libcap/Makefile
+index 47cf8f4..18e4f4f 100644
+--- a/libcap/Makefile
++++ b/libcap/Makefile
+@@ -105,7 +105,7 @@ empty: empty.c
+ 	$(CC) -o $@ $<
+ 
+ loader.txt: empty
+-	$(OBJCOPY) --dump-section .interp=/dev/stdout $< > $@
++	$(OBJCOPY) --dump-section .interp=$@ $< /dev/null
+ 
+ cap_magic.o: execable.h execable.c loader.txt
+ 	$(CC) $(CFLAGS) $(IPATH) -DLIBRARY_VERSION=\"$(LIBTITLE)-$(VERSION).$(MINOR)\" -DSHARED_LOADER=\"$(shell cat loader.txt)\" -c execable.c -o $@
+-- 
+2.31.1
+
Signature · 6 lines
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#1 lore raw

Arnout, All,

On 2021-08-24 01:31 +0200, Arnout Vandecappelle (Essensium/Mind) spake thusly:

Quoted 18 lines

Upstream commit [1] introduced an invocation of objcopy to generat loader.txt. However, objcopy, if not provided with an output file, will overwrite the input file. This is usually harmless because it will be identical, but the timestamp is updated. This may cause 'empty' to be newer than 'loader.txt', which causes 'loader.txt' and its dependencies to be rebuilt during 'make install'

We provide a different set of parameters during 'make install'. In particular, we no longer pass in HOST_CONFIGURE_OPTS, so we no longer set LDFLAGS. Thus, there is no -Wl,rpath option that is passed in, which causes the resulting binaries to have an incorrect RPATH.

Fix this by adding /dev/null as the output file in the objcopy invocation.

Patch was sent upstream, but there's no mailing list, just a single person.

Quoted 6 lines

Fixes: http://autobuild.buildroot.net/results/600/600aff5b839b48db80751cace5fa9670b7a3d698
(hopefully)

[1] https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=efd293947f940180eedd8d0915b124f4aedccc08

Applied to master, then reverted, then applied to next, thanks.

/me goes grab a third coffee before resuming patch reviews...

Regards,
Yann E. MORIN.

Quoted 68 lines

---
Note: I tried updating to v1.2.53 first, but that failed due to [2]

[2] https://bugzilla.kernel.org/show_bug.cgi?id=214023#c16

---
 ...don-t-overwrite-empty-when-generatin.patch | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 package/libcap/0001-libcap-Makefile-don-t-overwrite-empty-when-generatin.patch
package/libcap/0001-libcap-Makefile-don-t-overwrite-empty-when-generatin.patch new file +50 -0
new file mode 100644
index 0000000000..a47a2c788e
@@ -0,0 +1,50 @@
+From dc507a812d931c24f1ac98c811fdd29bffa21da9 Mon Sep 17 00:00:00 2001
+From: "Arnout Vandecappelle (Essensium/Mind)" <[email protected]>
+Date: Tue, 24 Aug 2021 00:36:40 +0200
+Subject: [PATCH] libcap/Makefile: don't overwrite 'empty' when generating
+ loader.txt
+
+objcopy takes an input file and an output file as arguments. If the
+output file is left out, the input file will be overwritten.
+
+Since the objcopy command used to generate loader.txt only does a
+dump-section and no filtering, in practice there is no change to empty.
+However, as a side-effect, its timestamp is updated. The timestamp of
+empty and of loader.txt will be more or less the same; however,
+loader.txt is closed just before the output file is closed, so it's
+possible that the timestamp of loader.txt is just a little bit earlier.
+If this happens, it causes loader.txt to be rebuilt later, which in turn
+causes a number of other object files to be rebuilt.
+
+Usually that's harmless, but it sometimes causes the rebuild to happen
+during 'make install'. This is particularly annoying if 'make install'
+is done as root, since loader.txt becomes owned by root in that case.
+
+Fix this by specifying a harmless output file: /dev/null.
+
+While we're at it, take in an upstream change that removes the redundant
+redirect.
+
+Fixes: ee3b25c0a877fa74d1aec88f325ac45b09963c82
+
+Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
+---
+ libcap/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libcap/Makefile b/libcap/Makefile
+index 47cf8f4..18e4f4f 100644
+--- a/libcap/Makefile
++++ b/libcap/Makefile
+@@ -105,7 +105,7 @@ empty: empty.c
+ 	$(CC) -o $@ $<
+ 
+ loader.txt: empty
+-	$(OBJCOPY) --dump-section .interp=/dev/stdout $< > $@
++	$(OBJCOPY) --dump-section .interp=$@ $< /dev/null
+ 
+ cap_magic.o: execable.h execable.c loader.txt
+ 	$(CC) $(CFLAGS) $(IPATH) -DLIBRARY_VERSION=\"$(LIBTITLE)-$(VERSION).$(MINOR)\" -DSHARED_LOADER=\"$(shell cat loader.txt)\" -c execable.c -o $@
+-- 
+2.31.1
+
Signature · 1 line
2.31.1
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#2 lore raw
Quoted 21 lines · Yann E. MORIN

Arnout, All,

On 2021-08-24 01:31 +0200, Arnout Vandecappelle (Essensium/Mind) spake thusly:

Quoted 18 lines

Upstream commit [1] introduced an invocation of objcopy to generat loader.txt. However, objcopy, if not provided with an output file, will overwrite the input file. This is usually harmless because it will be identical, but the timestamp is updated. This may cause 'empty' to be newer than 'loader.txt', which causes 'loader.txt' and its dependencies to be rebuilt during 'make install'

We provide a different set of parameters during 'make install'. In particular, we no longer pass in HOST_CONFIGURE_OPTS, so we no longer set LDFLAGS. Thus, there is no -Wl,rpath option that is passed in, which causes the resulting binaries to have an incorrect RPATH.

Fix this by adding /dev/null as the output file in the objcopy invocation.

Patch was sent upstream, but there's no mailing list, just a single person.

Quoted 8 lines
Quoted 6 lines

Fixes: http://autobuild.buildroot.net/results/600/600aff5b839b48db80751cace5fa9670b7a3d698
(hopefully)

[1] https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=efd293947f940180eedd8d0915b124f4aedccc08

Applied to master, then reverted, then applied to next, thanks.

Ah, sorry, I forgot to add the /next part... Well, it was already late :-)

Regards,
Arnout

Quoted 66 lines

/me goes grab a third coffee before resuming patch reviews...

Regards,
Yann E. MORIN.

Quoted 60 lines

---
Note: I tried updating to v1.2.53 first, but that failed due to [2]

[2] https://bugzilla.kernel.org/show_bug.cgi?id=214023#c16

---
 ...don-t-overwrite-empty-when-generatin.patch | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 package/libcap/0001-libcap-Makefile-don-t-overwrite-empty-when-generatin.patch
package/libcap/0001-libcap-Makefile-don-t-overwrite-empty-when-generatin.patch new file +45 -0
new file mode 100644
index 0000000000..a47a2c788e
@@ -0,0 +1,50 @@
+From dc507a812d931c24f1ac98c811fdd29bffa21da9 Mon Sep 17 00:00:00 2001
+From: "Arnout Vandecappelle (Essensium/Mind)" <[email protected]>
+Date: Tue, 24 Aug 2021 00:36:40 +0200
+Subject: [PATCH] libcap/Makefile: don't overwrite 'empty' when generating
+ loader.txt
+
+objcopy takes an input file and an output file as arguments. If the
+output file is left out, the input file will be overwritten.
+
+Since the objcopy command used to generate loader.txt only does a
+dump-section and no filtering, in practice there is no change to empty.
+However, as a side-effect, its timestamp is updated. The timestamp of
+empty and of loader.txt will be more or less the same; however,
+loader.txt is closed just before the output file is closed, so it's
+possible that the timestamp of loader.txt is just a little bit earlier.
+If this happens, it causes loader.txt to be rebuilt later, which in turn
+causes a number of other object files to be rebuilt.
+
+Usually that's harmless, but it sometimes causes the rebuild to happen
+during 'make install'. This is particularly annoying if 'make install'
+is done as root, since loader.txt becomes owned by root in that case.
+
+Fix this by specifying a harmless output file: /dev/null.
+
+While we're at it, take in an upstream change that removes the redundant
+redirect.
+
+Fixes: ee3b25c0a877fa74d1aec88f325ac45b09963c82
+
+Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
+---
+ libcap/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libcap/Makefile b/libcap/Makefile
+index 47cf8f4..18e4f4f 100644
+--- a/libcap/Makefile
++++ b/libcap/Makefile
+@@ -105,7 +105,7 @@ empty: empty.c
+ 	$(CC) -o $@ $<
+ 
+ loader.txt: empty
+-	$(OBJCOPY) --dump-section .interp=/dev/stdout $< > $@
++	$(OBJCOPY) --dump-section .interp=$@ $< /dev/null
+ 
Quoted 9 lines
Quoted 8 lines
package/libcap/0001-libcap-Makefile-don-t-overwrite-empty-when-generatin.patch new file +5 -0
+ cap_magic.o: execable.h execable.c loader.txt
+ 	$(CC) $(CFLAGS) $(IPATH) -DLIBRARY_VERSION=\"$(LIBTITLE)-$(VERSION).$(MINOR)\" -DSHARED_LOADER=\"$(shell cat loader.txt)\" -c execable.c -o $@
+-- 
+2.31.1
+
Signature · 1 line
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot