{"id":809134,"url":"http://patchwork.ozlabs.org/api/patches/809134/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/patch/20170902180801.27348-1-jrtc27@jrtc27.com/","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170902180801.27348-1-jrtc27@jrtc27.com>","list_archive_url":null,"date":"2017-09-02T18:08:01","name":"Fix TLS relocations against local symbols on powerpc32, sparc32 and sparc64","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"91d3a140e36ddd3676639f3dc1e968a24865acba","submitter":{"id":64682,"url":"http://patchwork.ozlabs.org/api/people/64682/?format=json","name":"Jessica Clarke","email":"jrtc27@jrtc27.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/20170902180801.27348-1-jrtc27@jrtc27.com/mbox/","series":[{"id":1174,"url":"http://patchwork.ozlabs.org/api/series/1174/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/list/?series=1174","date":"2017-09-02T18:08:01","name":"Fix TLS relocations against local symbols on powerpc32, sparc32 and sparc64","version":1,"mbox":"http://patchwork.ozlabs.org/series/1174/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/809134/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809134/checks/","tags":{},"related":[],"headers":{"Return-Path":"<libc-alpha-return-84122-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-84122-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"wUvORzkI\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xl3xz43fjz9s7p\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun,  3 Sep 2017 04:08:22 +1000 (AEST)","(qmail 43916 invoked by alias); 2 Sep 2017 18:08:16 -0000","(qmail 43905 invoked by uid 89); 2 Sep 2017 18:08:16 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id; q=dns; s=\n\tdefault; b=U9U3ty2YOC/gE9qmSNtiYQ1cZ5uG6aUoFegAGGtS7B8sOD6g9dZ+d\n\tpraVr2Xws1hM/GzixXLOt1OnLPnjIvDk3tg9H/dypJV+c0kkxVd/j3YiapccJEhg\n\t5yAxhGo91EhOqRN9S/B6KtN2DN0OH1Sal3qr0GbS2pE+M3cEbgAyX0=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id; s=default;\n\tbh=vWFvONixM+1wrhXpOCnetZeS/TI=; b=wUvORzkITkCcsjmTcu3dNWHYahdx\n\taDeS8lZHrnqUF4H9kbIfjTXqp+P8DEe8fd+wcMtPwaXhg5W7XAjTzku5Mfv81ART\n\tPpyTko7yrrFidwi/VGaeJmm0ETLX33Eh7RLTdN2d/tlhJujeFSnxAaeNCl5LTYlI\n\tdTwrLq3vHUNxo7o=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=","X-HELO":"mail-wm0-f44.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id;\n\tbh=n35zssRVPzTmq/NA4kKkBfBjdRGE9wT4m6XHdhMuuYY=;\n\tb=NHnkJX1w04cZmBqLKsSt4s3i8YDh1/opcllRd6UFGn/EL88IvHiS4Mv9jekScFtDQW\n\tnGNT+nY5OQsFOOFV+fgnk8blFSn0dIYYUj0SivMKH9D2TQWQ2aEfzcMkKnH8eA+pNmdX\n\tv4d+4WnScc3Eh28rBauSwmWtWtzlkw4cPROMGJbLt4V7se6m6pdn1KKmlD0/gSgSSSS9\n\tk8xCoc6kw9ANYTL0ZvtOkktTbCOz7fDXSPHWhbmS+QRcb4YyALkqLBvHK5O1ufrolwU4\n\t0VrPz9xQ9nAir0CK5BRpKmaB0q3rdjRFz5/E1A1zng7NwFwdtEC2jxgG7wZV31jWs/Ma\n\tMO+g==","X-Gm-Message-State":"AHPjjUjs6321EmECgpF3eS4J+/y+NCz4Wh78klb1F45vRilMB6F+aANe\n\tZ4KPWT9QQ0hTCyqjDm0oDw==","X-Google-Smtp-Source":"ADKCNb5vdmF8XBORryq2VKMKs39NR1efIHaHXs+uBqH/eDueasLjAHy2JASfRItmLFoefyr8VFYyow==","X-Received":"by 10.28.210.8 with SMTP id j8mr1039578wmg.164.1504375688557;\n\tSat, 02 Sep 2017 11:08:08 -0700 (PDT)","From":"James Clarke <jrtc27@jrtc27.com>","To":"libc-alpha@sourceware.org","Cc":"James Clarke <jrtc27@jrtc27.com>","Subject":"[PATCH] Fix TLS relocations against local symbols on powerpc32,\n\tsparc32 and sparc64","Date":"Sat,  2 Sep 2017 19:08:01 +0100","Message-Id":"<20170902180801.27348-1-jrtc27@jrtc27.com>"},"content":"* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela):\n\tAssign sym_map to be map for local symbols, as TLS relocations\n\tuse sym_map to determine whether the symbol is defined and to\n\textract the TLS information.\n\t* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela):\n\tLikewise.\n\t* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela):\n\tLikewise.\n---\n sysdeps/powerpc/powerpc32/dl-machine.h | 5 ++++-\n sysdeps/sparc/sparc32/dl-machine.h     | 1 +\n sysdeps/sparc/sparc64/dl-machine.h     | 1 +\n 3 files changed, 6 insertions(+), 1 deletion(-)\n\nNormally, TLS relocations against local symbols are optimised by the linker to\nbe absolute. However, gold does not do this, and so it is possible to end up\nwith, for example, R_SPARC_TLS_DTPMOD64 referring to a local symbol. Since\nsym_map is left as null in elf_machine_rela for the special local symbol case,\nthe relocation handling thinks it has nothing to do, and so the module gets\nleft as 0. Havoc then ensues when the variable in question is accessed. I have\nwritten http://paste.debian.net/plain/984146 to demonstrate the problem. Before\nthis fix, the main_local_gold program would receive a SIGBUS on sparc64, and\nSIGSEGV on powerpc32. With this fix applied, that test now passes like the rest\nof them.\n\n--\n2.14.1","diff":"diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h\nindex 1f8437ed9c..c19b3b7a16 100644\n--- a/sysdeps/powerpc/powerpc32/dl-machine.h\n+++ b/sysdeps/powerpc/powerpc32/dl-machine.h\n@@ -310,7 +310,10 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,\n      against local symbols.  */\n   if (__builtin_expect (ELF32_ST_BIND (sym->st_info) == STB_LOCAL, 0)\n       && sym->st_shndx != SHN_UNDEF)\n-    value = map->l_addr;\n+    {\n+      sym_map = map;\n+      value = map->l_addr;\n+    }\n   else\n     {\n       sym_map = RESOLVE_MAP (&sym, version, r_type);\ndiff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h\nindex 436e4e6cc3..debf67bd1b 100644\n--- a/sysdeps/sparc/sparc32/dl-machine.h\n+++ b/sysdeps/sparc/sparc32/dl-machine.h\n@@ -376,6 +376,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,\n   if (__builtin_expect (ELF32_ST_BIND (sym->st_info) == STB_LOCAL, 0)\n       && sym->st_shndx != SHN_UNDEF)\n     {\n+      sym_map = map;\n       value = map->l_addr;\n     }\n   else\ndiff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h\nindex c2871dca3a..e1ec7a532c 100644\n--- a/sysdeps/sparc/sparc64/dl-machine.h\n+++ b/sysdeps/sparc/sparc64/dl-machine.h\n@@ -403,6 +403,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,\n   if (__builtin_expect (ELF64_ST_BIND (sym->st_info) == STB_LOCAL, 0)\n       && sym->st_shndx != SHN_UNDEF)\n     {\n+      sym_map = map;\n       value = map->l_addr;\n     }\n   else\n","prefixes":[]}