<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><br>
</p>
<div class="moz-cite-prefix">On 02/20/2017 08:16 PM, Rui Ueyama
wrote:<br>
</div>
<blockquote
cite="mid:CAJENXgsP8yEkBoCSF=Gi-UhuKzROdh8=zAezhbYav5TXWeDFEQ@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<div dir="ltr">Are you suggesting I bring it up to the LLVM blog?
This comment is my opinion, and I guess not everybody agrees we
should avoid exporting globals from DSOs.</div>
</blockquote>
<br>
Either the LLVM blog or some other. If you feel that your opinion is
controversial, you could stick to the facts about what becomes part
of the ABI.<br>
<br>
-Hal <br>
<br>
<blockquote
cite="mid:CAJENXgsP8yEkBoCSF=Gi-UhuKzROdh8=zAezhbYav5TXWeDFEQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Feb 20, 2017 at 7:49 AM, Hal
Finkel <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Rui,<br>
<br>
I certainly found this informative, thanks for writing
this. I think this would also be a good topic for a blog
post; those will get a larger audience.<br>
<br>
-Hal
<div class="m_-7238474665183767036HOEnZb">
<div class="m_-7238474665183767036h5"><br>
<br>
<br>
On 02/19/2017 08:22 PM, Rui Ueyama via llvm-commits
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: ruiu<br>
Date: Sun Feb 19 20:22:56 2017<br>
New Revision: 295632<br>
<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project?rev=295632&view=rev"
rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=295632&view=rev</a><br>
Log:<br>
Add more comments about copy relocations.<br>
<br>
Modified:<br>
lld/trunk/ELF/Relocations.cpp<br>
<br>
Modified: lld/trunk/ELF/Relocations.cpp<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=295632&r1=295631&r2=295632&view=diff"
rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Relocation<wbr>s.cpp?rev=295632&r1=295631&r2=<wbr>295632&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Relocations.cpp (original)<br>
+++ lld/trunk/ELF/Relocations.cpp Sun Feb 19
20:22:56 2017<br>
@@ -461,6 +461,21 @@ static
std::vector<SharedSymbol<ELFT> *><br>
// dynamic linker, and the relocation contains not
only symbol name but<br>
// various other informtion about the symbol. So,
such attributes become a<br>
// part of the ABI.<br>
+//<br>
+// Note for application developers: I can give you
a piece of advice if<br>
+// you are writing a shared library. You probably
should export only<br>
+// functions from your library. You shouldn't
export variables.<br>
+//<br>
+// As an example what can happen when you export
variables without knowing<br>
+// the semantics of copy relocations, assume that
you have an exported<br>
+// variable of type T. It is an ABI-breaking change
to add new members at<br>
+// end of T even though doing that doesn't change
the layout of the<br>
+// existing members. That's because the space for
the new members are not<br>
+// reserved in .bss unless you recompile the main
program. That means they<br>
+// are likely to overlap with other data that
happens to be laid out next<br>
+// to the variable in .bss. This kind of issue is
sometimes very hard to<br>
+// debug. What's a solution? Instead of exporting a
varaible V from a DSO,<br>
+// define an accessor getV().<br>
template <class ELFT> static void
addCopyRelSymbol(SharedSymbol<<wbr>ELFT> *SS)
{<br>
typedef typename ELFT::uint uintX_t;<br>
@@ -482,10 +497,10 @@ template <class ELFT>
static void addCop<br>
// Look through the DSO's dynamic symbol table
for aliases and create a<br>
// dynamic symbol for each one. This causes the
copy relocation to correctly<br>
// interpose any aliases.<br>
- for (SharedSymbol<ELFT> *Alias :
getSymbolsAt(SS)) {<br>
- Alias->NeedsCopy = true;<br>
- Alias->Section = ISec;<br>
- Alias->symbol()->IsUsedInRegul<wbr>arObj
= true;<br>
+ for (SharedSymbol<ELFT> *Sym :
getSymbolsAt(SS)) {<br>
+ Sym->NeedsCopy = true;<br>
+ Sym->Section = ISec;<br>
+ Sym->symbol()->IsUsedInRegular<wbr>Obj =
true;<br>
}<br>
In<ELFT>::RelaDyn->addReloc({T<wbr>arget->CopyRel,
ISec, 0, false, SS, 0});<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a moz-do-not-send="true"
href="mailto:llvm-commits@lists.llvm.org"
target="_blank">llvm-commits@lists.llvm.org</a><br>
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits"
rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote>
<br>
</div>
</div>
<span class="m_-7238474665183767036HOEnZb"><font
color="#888888">
-- <br>
Hal Finkel<br>
Lead, Compiler Technology and Programming Languages<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
<br>
</font></span></blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>