<div dir="ltr"><div>FYI, I just pushed the new linker.</div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 3, 2019 at 10:39 PM Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu">jan.vesely@rutgers.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Fixes piglits:<br>
        <a href="http://call.cl" rel="noreferrer" target="_blank">call.cl</a><br>
        <a href="http://calls-larget-struct.cl" rel="noreferrer" target="_blank">calls-larget-struct.cl</a><br>
        <a href="http://calls-struct.cl" rel="noreferrer" target="_blank">calls-struct.cl</a><br>
        <a href="http://calls-workitem-id.cl" rel="noreferrer" target="_blank">calls-workitem-id.cl</a><br>
        <a href="http://realign-stack.cl" rel="noreferrer" target="_blank">realign-stack.cl</a><br>
        <a href="http://tail-calls.cl" rel="noreferrer" target="_blank">tail-calls.cl</a><br>
<br>
Cc: <a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a><br>
Signed-off-by: Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu" target="_blank">jan.vesely@rutgers.edu</a>><br>
---<br>
The piglit test now pass using llvm-7,8,git.<br>
ImageMagick works on my raven, but some test still fail on<br>
carrizo/iceland.<br>
Other workloads (like shoc) that used function calls also work ok.<br>
ocltoys work after removing static keyword from .cl files.<br>
 src/amd/common/ac_binary.c                | 30 +++++++++++++++++++++++<br>
 src/gallium/drivers/radeonsi/si_compute.c |  6 -----<br>
 2 files changed, 30 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/amd/common/ac_binary.c b/src/amd/common/ac_binary.c<br>
index 18dc72c61f0..4d152fcf1be 100644<br>
--- a/src/amd/common/ac_binary.c<br>
+++ b/src/amd/common/ac_binary.c<br>
@@ -178,6 +178,36 @@ bool ac_elf_read(const char *elf_data, unsigned elf_size,<br>
<br>
        parse_relocs(elf, relocs, symbols, symbol_sh_link, binary);<br>
<br>
+       // Apply relocations<br>
+       for (int i = 0; i < binary->reloc_count; ++i) {<br>
+               struct ac_shader_reloc *r = &binary->relocs[i];<br>
+               uint32_t *loc = (uint32_t*)(binary->code + r->offset);<br>
+               /* Section target relocations store symbol offsets as<br>
+                * values in reloc location. We're expected to adjust it for<br>
+                * start of the section. However, R_AMDGPU_REL32 are<br>
+                * PC relative relocations, so we need to recompute the<br>
+                * delta between reloc locatin and the target adress.<br>
+                */<br>
+               if (r->target_type == 0x3) { // section relocation<br>
+                       uint32_t target_offset = *loc; // already adjusted<br>
+                       int64_t diff = target_offset - r->offset;<br>
+                       if (r->type == 0xa) { // R_AMDGPU_REL32_LO<br>
+                               // address of the 'lo' instruction is 4B below<br>
+                               // the relocation point, but the target has<br>
+                               // alredy been adjusted.<br>
+                               *loc = (diff & 0xffffffff);<br>
+                       } else if (r->type == 0xb) { // R_AMDGPU_REL32_HI<br>
+                               // 'hi' relocation is 8B above 'lo' relocation<br>
+                               *loc = ((diff - 8) >> 32);<br>
+                       } else {<br>
+                               success = false;<br>
+                               fprintf(stderr, "Unsupported section relocation: type: %d, offset: %lx, value: %x\n",<br>
+                                               r->type, r->offset, *loc);<br>
+                       }<br>
+               } else<br>
+                       success = false;<br>
+       }<br>
+<br>
        if (elf){<br>
                elf_end(elf);<br>
        }<br>
diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c<br>
index b9cea00eeeb..88631369a62 100644<br>
--- a/src/gallium/drivers/radeonsi/si_compute.c<br>
+++ b/src/gallium/drivers/radeonsi/si_compute.c<br>
@@ -246,12 +246,6 @@ static void *si_create_compute_state(<br>
                        const amd_kernel_code_t *code_object =<br>
                                si_compute_get_code_object(program, 0);<br>
                        code_object_to_config(code_object, &program->shader.config);<br>
-                       if (program->shader.binary.reloc_count != 0) {<br>
-                               fprintf(stderr, "Error: %d unsupported relocations\n",<br>
-                                       program->shader.binary.reloc_count);<br>
-                               FREE(program);<br>
-                               return NULL;<br>
-                       }<br>
                } else {<br>
                        si_shader_binary_read_config(&program->shader.binary,<br>
                                     &program->shader.config, 0);<br>
-- <br>
2.21.0<br>
<br>
_______________________________________________<br>
mesa-stable mailing list<br>
<a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-stable" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-stable</a></blockquote></div>