<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p id="reply-intro">On 2020-09-16 19:42, Fangrui Song wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap;">On 2020-09-16, Gaël Jobin wrote:</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><br /><span style="white-space: nowrap;">Your example uses global mutable variables "test" and "unused" and that</span><br /><span style="white-space: nowrap;">is why they are in the .data.* sections. They are initialized to</span><br /><span style="white-space: nowrap;">addresses of string literals in .rodata.* . .rodata.* are what we care</span><br /><span style="white-space: nowrap;">about, not .data.* (.data.* can always be correctly garbage collected by</span><br /><span style="white-space: nowrap;">GNU ld/gold/LLD).</span></div>
</blockquote>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">Of course, the issue here is .rodata.*. I use the .data.* section as a counterexample</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">but it could be any section.  </span></span><span style="font-family: verdana, geneva, sans-serif; white-space: nowrap; font-size: 10pt;">I compare </span><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">those two sections because they contain both</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;"> small datas and the ratio "section header </span><span style="font-family: verdana, geneva, sans-serif; white-space: nowrap; font-size: 10pt;">size" vs "data size" is not optimal.</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">But my point is: Why the implementation of </span><span style="font-family: verdana, geneva, sans-serif; white-space: nowrap; font-size: 10pt;">-fdata-sections should differ between .data.*</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="font-family: verdana, geneva, sans-serif; white-space: nowrap; font-size: 10pt;">and .rodata.* sections? Or why .rodata.* should be treated differently?</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">If the only </span><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">reason is because it is suboptimal due to the additional section header,</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">this is definitely not a valid reason. Having everything in its own section is the</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">purpose of the -f*-sections and allows the linker to easily strip them. I really</span></div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap; font-family: verdana, geneva, sans-serif;">don't get the exception made for .rodata.* here.</span></div>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
</blockquote>

</body></html>