<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://sourceware.org/bugzilla/bugzilla.dtd">

<bugzilla version="4.0.10"
          urlbase="http://sourceware.org/bugzilla/"
          
          maintainer="overseers@sourceware.org"
>

    <bug>
          <bug_id>14603</bug_id>
          
          <creation_ts>2012-09-21 08:43:00 +0000</creation_ts>
          <short_desc>no reloc emitted for ld generated veneers for ARM</short_desc>
          <delta_ts>2012-09-21 11:09:02 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>binutils</product>
          <component>ld</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>REOPENED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marcin Bukat">marcin.bukat</reporter>
          <assigned_to name="Not yet assigned to anyone">unassigned</assigned_to>
          <cc>mgretton</cc>
          <cf_gcchost></cf_gcchost>
          <cf_gcctarget></cf_gcctarget>
          <cf_gccbuild></cf_gccbuild>
          

      

      

      

          <long_desc isprivate="0">
            <commentid>57520</commentid>
              <attachid>6642</attachid>
            <who name="Marcin Bukat">marcin.bukat</who>
            <bug_when>2012-09-21 08:43:49 +0000</bug_when>
            <thetext>Created attachment 6642
testcase

The simple test case provided shows that 0x80000000 constant used as jump address in veneer generated by ld has no reloc associated. I believe this is a bug (or inconsistency at least). I noticed this working on bFLT loader for the target with memory split - fast internal ram and regular dram. With current ld behavior runtime relocation is broken by this.

The workaround is to use -mlong-calls when compiling C sources but this imposes performance penalty as well as does not solve the problem of asm files.

Tested with 2.20.1 as well as with current snapshot.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>57522</commentid>
            <who name="Matthew Gretton-Dann">mgretton</who>
            <bug_when>2012-09-21 09:13:48 +0000</bug_when>
            <thetext>The testcase doesn&apos;t mark the branch destination as a function.  The linker will only veneer function calls.

The test should work fine with the following source:

.text
.arm
.global _start
_start:
    bl far_foo

.section .far_text,&quot;ax&quot;
.arm
.global far_foo
.type far_foo, %function
@ For thumb you would instead do: .thumb_func
far_foo:
    nop
    bx lr 

For further examples see ld/testsuite/ld-arm/farcall-*.s source files.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>57523</commentid>
            <who name="Marcin Bukat">marcin.bukat</who>
            <bug_when>2012-09-21 09:19:32 +0000</bug_when>
            <thetext>Running provided testcase I get this:

test.elf:     file format elf32-littlearm


Disassembly of section .text:

00000000 &lt;_start&gt;:
   0:	eb000000 	bl	8 &lt;__far_foo_veneer&gt;
			0: R_ARM_CALL	far_foo
   4:	00000000 	andeq	r0, r0, r0

00000008 &lt;__far_foo_veneer&gt;:
   8:	e51ff004 	ldr	pc, [pc, #-4]	; c &lt;__far_foo_veneer+0x4&gt;
   c:	80000000 	.word	0x80000000

Disassembly of section .far_text:

80000000 &lt;far_foo&gt;:
80000000:	e1a00000 	nop			; (mov r0, r0)
80000004:	e12fff1e 	bx	lr
			80000004: R_ARM_V4BX	*ABS*


There is clearly veneer inserted as well as with your proposed change. But this is not the case. The bug is about lack of relocation in veneer jump address which still holds.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>57524</commentid>
            <who name="Matthew Gretton-Dann">mgretton</who>
            <bug_when>2012-09-21 09:43:34 +0000</bug_when>
            <thetext>Surely as you have linked the image together and it is now fully relocated, the linker doesn&apos;t need to create relocations for veneers?

The test case you provide only contains static relocations.  These are applied once at static link time, and cannot - in general - be reapplied after linking (as if the relocations have been specified with .rel sections the necessary addend has been destroyed).

If you want to do runtime linking and relocation you need to use dynamic relocations which do not get fixed by the static linker.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>57525</commentid>
            <who name="Marcin Bukat">marcin.bukat</who>
            <bug_when>2012-09-21 11:09:02 +0000</bug_when>
            <thetext>elf2flt allows you to take fully resolved elf binary produced with --emit-relocs and produce flat file which is relocated at load time. I want to archive the same but with address space split. I do understand why usually it is not needed but veneer inserted by ld can be seen like any other code coming from object files. It does introduce new symbols, but does not create relocation for this symbols. I see this as inconsistency at least.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
              isurl="0"
          >
            <attachid>6642</attachid>
            <date>2012-09-21 08:43:00 +0000</date>
            <delta_ts>2012-09-21 08:43:49 +0000</delta_ts>
            <desc>testcase</desc>
            <filename>arm-eabi-test.tar.bz2</filename>
            <type>application/x-bzip</type>
            <size>598</size>
            <attacher>marcin.bukat</attacher>
            
              <data encoding="base64">QlpoOTFBWSZTWYS/tvwAAbh/xMywQEBUd//Tf//eIf+//toQAAAAwAhAAjzswjawSiJGI2pqbEmj
1A0ABo9INANBpp6gaNHqHDTTBDIaaZGTCAaaAMJo0yYAEDQSJUTyRk3qT0gPUAAAAAMgABoAJQQQ
hqntUwn6TKDCYNQHqYhjQm1G0mmmGjy7gy9hqaqYZSBboqAi0IgCYMMiwoAdHxNid2a/EKAJogog
DMChSn7zt+o+FkYbOd49m6c1XhR/q6lTQIY72fglatNLzirOyTJ69tFCAvNJg0gvkJA+PMGS322x
zossSPgrS0eWLrFZh8Zzzg5Cc1HIp0ZlHks5GDz980lVDlDAD8jcJNGsriWgHrJeoa36XWSwiO4q
oobBekYeCURjZIklIaJygE0xgXkQtUEPyZunN1QuAkgLWVUYDgB7gPAFDIuW1gJuHCrOHDSQL8Wm
sVkwUQojVApKVAZIsTR6kqHOsYgtMpsBInYmPS+l42vWrIJtHqL+tgjnLc0wwmzS0h2ykxmAoMkR
SN0fUUpLMqrKMk9jHGNLi78D0BM8o6KSFGxtkYy0rCSOstMxDRcJ0yDuNCSbOalsK6JJ8lZuuF4Q
9yGqr4ntJAlz03DKiLbI48T6mauAz+HkRnh+2yqncRZAJjHYalNBK1F+rW0oClKmxGHYcOUxy+NQ
kdBdUewVVRQHK6zU1aIXBy6M1Y/kBXYmSbFmnwAhiGzgaR6VyIjCEWQkuKhpsyRENKXQFnVwWIFF
LsY6oLoVBPJ4BKI+A4IyAED/F3JFOFCQhL+2/A==
</data>

          </attachment>
      

    </bug>

</bugzilla>