NetBSD Problem Report #51304

From www@NetBSD.org  Sun Jul  3 06:57:39 2016
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3C2117A471
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  3 Jul 2016 06:57:39 +0000 (UTC)
Message-Id: <20160703065737.E76D27AB3C@mollari.NetBSD.org>
Date: Sun,  3 Jul 2016 06:57:37 +0000 (UTC)
From: richard@NetBSD.org
Reply-To: richard@NetBSD.org
To: gnats-bugs@NetBSD.org
Cc: joern.clausen@uni-bielefeld.de
Subject: luatex suffers from luajit generating non-PIC code
X-Send-Pr-Version: www-1.0

>Number:         51304
>Category:       pkg
>Synopsis:       luatex suffers from luajit generating non-PIC code
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 03 07:00:00 +0000 2016
>Last-Modified:  Tue Jul 05 01:22:01 +0000 2016
>Originator:     Richard PALO
>Release:        current
>Organization:
>Environment:
SunOS omnis 5.11 omnios-master-7397b49 i86pc i386 i86pc

>Description:
As initially reported in pkgsrc-users@

Seems luajit is reactivated, and one of its assembler files generated (lj_vm_asm.S) destined to be put in a shared library is non-PIC.

Looks like gnu-ld is tolerant of R_*_PC32 relocations here, but sun-ld wants R_*_PLT32 else it balks with:
> ...
> Text relocation remains                 	referenced
>     against symbol		    offset	in file
> lj_gc_step                          0x30b8    	.libs/lj_vm_asm.o
> lj_tab_len                          0x503     	.libs/lj_vm_asm.o
> lj_tab_getinth                      0x1c5d    	.libs/lj_vm_asm.o
> lj_tab_getinth                      0x2286    	.libs/lj_vm_asm.o
> lj_state_growstack                  0x1328    	.libs/lj_vm_asm.o
> lj_state_growstack                  0x194d    	.libs/lj_vm_asm.o
> lj_state_growstack                  0x19cc    	.libs/lj_vm_asm.o
> lj_state_growstack                  0x2470    	.libs/lj_vm_asm.o
> lj_state_growstack                  0x257e    	.libs/lj_vm_asm.o
> lj_state_growstack                  0x3093    	.libs/lj_vm_asm.o
> lj_ffh_coroutine_wrap_err           0x256f    	.libs/lj_vm_asm.o
> lj_str_new                          0x2b3a    	.libs/lj_vm_asm.o
> lj_tab_new                          0xb37     	.libs/lj_vm_asm.o
> lj_tab_setinth                      0x1d4c    	.libs/lj_vm_asm.o
> lj_tab_get                          0x20c3    	.libs/lj_vm_asm.o
> lj_err_throw                        0x337b    	.libs/lj_vm_asm.o
> lj_meta_tget                        0x1c12    	.libs/lj_vm_asm.o
> lj_meta_tset                        0x1cde    	.libs/lj_vm_asm.o
> lj_meta_equal                       0x1de0    	.libs/lj_vm_asm.o
> lj_meta_comp                        0x1d80    	.libs/lj_vm_asm.o
> lj_meta_cat                         0x88b     	.libs/lj_vm_asm.o
> lj_tab_next                         0x2193    	.libs/lj_vm_asm.o
> lj_buf_putstr_reverse               0x2c36    	.libs/lj_vm_asm.o
> lj_buf_putstr_lower                 0x2c88    	.libs/lj_vm_asm.o
> lj_buf_putstr_upper                 0x2cda    	.libs/lj_vm_asm.o
> lj_buf_tostr                        0x2c3d    	.libs/lj_vm_asm.o
> lj_buf_tostr                        0x2c8f    	.libs/lj_vm_asm.o
> lj_buf_tostr                        0x2ce1    	.libs/lj_vm_asm.o
> lj_ccallback_enter                  0x3611    	.libs/lj_vm_asm.o
> lj_ccallback_leave                  0x3659    	.libs/lj_vm_asm.o
> lj_dispatch_ins                     0x311f    	.libs/lj_vm_asm.o
> lj_dispatch_call                    0x3195    	.libs/lj_vm_asm.o
> lj_trace_hot                        0x316f    	.libs/lj_vm_asm.o
> lj_dispatch_stitch                  0x323a    	.libs/lj_vm_asm.o
> lj_dispatch_profile                 0x325e    	.libs/lj_vm_asm.o
> lj_func_closeuv                     0xaa3     	.libs/lj_vm_asm.o
> lj_func_newL_gc                     0xada     	.libs/lj_vm_asm.o
> lj_gc_step_fixtop                   0xb68     	.libs/lj_vm_asm.o
> lj_gc_step_fixtop                   0xbbd     	.libs/lj_vm_asm.o
> lj_gc_barrieruv                     0x9ef     	.libs/lj_vm_asm.o
> lj_gc_barrieruv                     0xa3d     	.libs/lj_vm_asm.o
> lj_strfmt_num                       0x2153    	.libs/lj_vm_asm.o
> lj_tab_dup                          0xb93     	.libs/lj_vm_asm.o
> lj_tab_newkey                       0xf0e     	.libs/lj_vm_asm.o
> lj_meta_arith                       0x1e68    	.libs/lj_vm_asm.o
> lj_meta_len                         0x1e9c    	.libs/lj_vm_asm.o
> lj_meta_equal_cd                    0x1dfa    	.libs/lj_vm_asm.o
> lj_meta_istype                      0x1e1b    	.libs/lj_vm_asm.o
> lj_meta_call                        0x1edc    	.libs/lj_vm_asm.o
> lj_meta_for                         0x1f1f    	.libs/lj_vm_asm.o
> lj_tab_reasize                      0x1022    	.libs/lj_vm_asm.o
> lj_trace_exit                       0x32f8    	.libs/lj_vm_asm.o
> lj_wrap_log                         0x2697    	.libs/lj_vm_asm.o
> lj_wrap_log10                       0x26c1    	.libs/lj_vm_asm.o
> lj_wrap_exp                         0x26eb    	.libs/lj_vm_asm.o
> lj_wrap_sin                         0x2715    	.libs/lj_vm_asm.o
> lj_wrap_cos                         0x273f    	.libs/lj_vm_asm.o
> lj_wrap_tan                         0x2769    	.libs/lj_vm_asm.o
> lj_wrap_asin                        0x2793    	.libs/lj_vm_asm.o
> lj_wrap_acos                        0x27bd    	.libs/lj_vm_asm.o
> lj_wrap_atan                        0x27e7    	.libs/lj_vm_asm.o
> lj_wrap_sinh                        0x2811    	.libs/lj_vm_asm.o
> lj_wrap_cosh                        0x283b    	.libs/lj_vm_asm.o
> lj_wrap_tanh                        0x2865    	.libs/lj_vm_asm.o
> lj_wrap_atan2                       0x28e3    	.libs/lj_vm_asm.o
> lj_wrap_pow                         0x84b     	.libs/lj_vm_asm.o
> lj_wrap_pow                         0x28a4    	.libs/lj_vm_asm.o
> lj_wrap_fmod                        0x2922    	.libs/lj_vm_asm.o
> ld: fatal: relocations remain against allocatable but non-writable sections
> collect2: error: ld returned 1 exit status
> gmake[2]: *** [Makefile:973: libtexluajit.la] Error 1

>How-To-Repeat:

>Fix:
This should be fixed correctly upstream, but a temporary workaround in pkgsrc may be the following patch:

richard@omnis:/home/richard/src/pkgsrc/print/luatex$ cat patches/patch-libs_luajit_Makefile.in 
$NetBSD$
Ensure that the luajit generated asm file is PIC for libtool use, particularly
important when linking under SunOS... appending @PLT seems to workaround the
issue with generated PC relative calls.

--- libs/luajit/Makefile.in.orig	2016-03-21 20:37:55.000000000 +0000
+++ libs/luajit/Makefile.in
@@ -1827,6 +1827,7 @@ lj_folddef.h: native/buildvm-stamp

 lj_vm_obj.o lj_vm_asm.S: native/buildvm-stamp
 	$(AM_V_GEN)native/buildvm -m $(LJVM_MODE) -o $@
+	test lj_vm_asm.S && $(SED) -i.orig 's/\(call lj_.*\)$$/\1@PLT/' lj_vm_asm.S

 lj_vm_obj.lo: lj_vm_obj.o lib_base.lo
 	$(AM_V_GEN)sed 's/lib_base/lj_vm_obj/' lib_base.lo >$@ \


BTW I needed to add 'gsed' to USE_TOOLS in order to use the simplified
inplace option to sed which nbsed doesn't support.

>Release-Note:

>Audit-Trail:
From: "Mark Davies" <markd@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51304 CVS commit: pkgsrc/print/luatex
Date: Sun, 3 Jul 2016 11:19:51 +0000

 Module Name:	pkgsrc
 Committed By:	markd
 Date:		Sun Jul  3 11:19:51 UTC 2016

 Modified Files:
 	pkgsrc/print/luatex: Makefile distinfo
 Added Files:
 	pkgsrc/print/luatex/patches: patch-libs_luajit_Makefile.in

 Log Message:
 workaround for luajit PIC issue PR pkg/51304  (also PR pkg/51260)


 To generate a diff of this commit:
 cvs rdiff -u -r1.47 -r1.48 pkgsrc/print/luatex/Makefile
 cvs rdiff -u -r1.18 -r1.19 pkgsrc/print/luatex/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/print/luatex/patches/patch-libs_luajit_Makefile.in

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51304 CVS commit: pkgsrc/print/luatex
Date: Tue, 5 Jul 2016 01:17:23 +0000

 Module Name:	pkgsrc
 Committed By:	dholland
 Date:		Tue Jul  5 01:17:23 UTC 2016

 Modified Files:
 	pkgsrc/print/luatex: Makefile distinfo
 	pkgsrc/print/luatex/patches: patch-libs_luajit_Makefile.in

 Log Message:
 remove gratuitous use of sed -i (related to PR 51304)


 To generate a diff of this commit:
 cvs rdiff -u -r1.48 -r1.49 pkgsrc/print/luatex/Makefile
 cvs rdiff -u -r1.19 -r1.20 pkgsrc/print/luatex/distinfo
 cvs rdiff -u -r1.1 -r1.2 \
     pkgsrc/print/luatex/patches/patch-libs_luajit_Makefile.in

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.