<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;">>I believe GNU linker prints out "relocations against text section; recomiple with -fPIC" warning if the linker is creating a DSO. Does >it warn on text relocations if no -shared is given?</span><br>
</p>
<div style="color: rgb(33, 33, 33);">
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">Depends on relocation. It will show this error for relocations that may be truncated in runtime:<br>
</div>
<div class="gmail_quote">
<div class="pre" style="font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);">
<a id="l2594" href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2594" class="linenr" style="color: rgb(153, 153, 153); text-decoration: none;">2594</a>
<span class="hl kwa" style="font-weight: bold;">case</span> R_X86_64_32<span class="hl opt">:</span></div>
<div class="pre" style="font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);">
<a id="l2595" href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2595" class="linenr" style="color: rgb(153, 153, 153); text-decoration: none;">2595</a>
<span class="hl kwa" style="font-weight: bold;">if</span> <span class="hl opt">(!</span><span class="hl kwd" style="color: rgb(1, 1, 129);">ABI_64_P</span>
<span class="hl opt">(</span>abfd<span class="hl opt">))</span></div>
<div class="pre" style="font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);">
<a id="l2596" href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2596" class="linenr" style="color: rgb(153, 153, 153); text-decoration: none;">2596</a>
<span class="hl kwa" style="font-weight: bold;">goto</span> pointer<span class="hl opt">;</span></div>
<div class="pre" style="font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);">
<a id="l2597" href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2597" class="linenr" style="color: rgb(153, 153, 153); text-decoration: none;">2597</a>
<span class="hl com" style="color: rgb(131, 129, 131); font-style: italic;">/* Fall through. */</span></div>
<div class="pre" style="font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);">
<a id="l2598" href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2598" class="linenr" style="color: rgb(153, 153, 153); text-decoration: none;">2598</a>
<span class="hl kwa" style="font-weight: bold;">case</span> R_X86_64_8<span class="hl opt">:</span></div>
<div class="pre" style="font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);">
<a id="l2599" href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2599" class="linenr" style="color: rgb(153, 153, 153); text-decoration: none;">2599</a>
<span class="hl kwa" style="font-weight: bold;">case</span> R_X86_64_16<span class="hl opt">:</span></div>
<div class="pre" style="font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);">
<a id="l2600" href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2600" class="linenr" style="color: rgb(153, 153, 153); text-decoration: none;">2600</a>
<span class="hl kwa" style="font-weight: bold;">case</span> R_X86_64_32S<span class="hl opt">:</span></div>
<br>
</div>
<div class="gmail_quote">But if you take <span style="color: rgb(33, 33, 33); font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);">R_X86_64_64:</span><br>
</div>
<div class="gmail_quote"><span style="color: rgb(33, 33, 33); font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);"><br>
</span></div>
<div class="gmail_quote">
<div>.text</div>
<div>.global _start</div>
<div>_start:</div>
<div> .quad _start</div>
<div><br>
<div>llvm-mc -filetype=obj -triple=x86_64-pc-linux test.s -o test.o</div>
<div>ld.bfd test.o -shared -o out<br>
</div>
<br>
</div>
<div>Then no error is produced and DT_<span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">TEXTREL</span> is added:<br>
</div>
<div><br>
</div>
<div>
<div> 0x0000000000000016 (TEXTREL)            0x0</div>
<div> 0x0000000000000000 (NULL)               0x0​<br>
</div>
<div>Relocation section '.rela.dyn' at offset 0x1e0 contains 1 entries:</div>
<div>  Offset          Info           Type           Sym. Value    Sym. Name + Addend</div>
<div>0000000001f8  000100000001 R_X86_64_64       00000000000001f8 _start + 0</div>
<div><br>
George.<br>
</div>
<br>
</div>
<span style="color: rgb(33, 33, 33); font-family: monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);"><br>
</span></div>
</div>
</div>
</div>
</body>
</html>