Bug 339862 - v6intThumb.c does not compile when -pie options is specified
Summary: v6intThumb.c does not compile when -pie options is specified
Status: CONFIRMED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-11 00:09 UTC by dimitry
Modified: 2025-03-29 20:35 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
v6intThumb.patch (709 bytes, patch)
2014-10-11 00:10 UTC, dimitry
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dimitry 2014-10-11 00:09:51 UTC
Android stopped supporting non-pie binaries with L-preview. 

The attached patch replaces movw/t instructions with ldr to prevent compiler from generating incompatible elf relocs

Reproducible: Always
Comment 1 dimitry 2014-10-11 00:10:39 UTC
Created attachment 89086 [details]
v6intThumb.patch
Comment 2 Mark Wielaard 2020-07-05 16:52:58 UTC
I am seeing something similar on debian-armhf:

gcc -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector    -g -O0 -mcpu=cortex-a8 -mthumb    -o v6intThumb v6intThumb-v6intThumb.o  
/usr/bin/ld: v6intThumb-v6intThumb.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
v6intThumb-v6intThumb.o: error adding symbols: Bad value

Note that it isn't exactly the same issue, because it isn't build with -fPIC or -pie, but using either -fPIC or -pie will produce the same issue.

The proposed patch doesn't work though. The assembler will then complain:
/tmp/ccveFwf0.s: Assembler messages:
/tmp/ccveFwf0.s:140: Error: offset out of range

It does seem to build on fedora-arm, so there are at least some configurations that do work. But it would be nice to see if this test could be written without relying on trying to load the address of a label.
Comment 3 Mark Wielaard 2025-03-29 20:35:43 UTC
For now I have disabled this test:

commit ae32e44d1e891dd2adbb056b0bb127b21efc1b67 (HEAD -> master)
Author: Mark Wielaard <mark@klomp.org>
Date:   Sat Mar 29 21:21:45 2025 +0100

    arm/v6intThumb: Disable tests for instructions modifying pc (ldr pc, add pc)
    
    The test doesn't compile.
    
    /usr/bin/ld: v6intThumb-v6intThumb.o(.text+0xf2): unresolvable
    R_ARM_THM_CALL relocation against symbol `printf@@GLIBC_2.4'
    
    Changing the movw and movt into a ldr as suggested in
    https://bugs.kde.org/show_bug.cgi?id=339862#c1
    Causes a different compile error.
    
    /tmp/ccveFwf0.s:140: Error: offset out of range
    
    So disable it for now.