This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Enable temporary labels symbol names
Needs ReviewPublic

Authored by lenykholodov on Nov 26 2015, 9:58 AM.
This revision needs review, but all reviewers have resigned.

Details

Reviewers
dexonsmith
Summary

After revision r236642 compiler prevents emitting of temp label names into object files to save memory. This creates problems for the binutils linker, which analyzes symbol names from the input object files and can skip some local compiler generated labels. As a result linker doesn't see the label names and therefore puts them all into the final binary as global symbols. Binutils require label names to have a prefix '.L'.

This patch fixes temporary label names generation for ELF.

Diff Detail

Repository
rL LLVM

Event Timeline

lenykholodov retitled this revision from to [ELF] Enable temporary labels symbol names.
lenykholodov updated this object.
lenykholodov added a reviewer: dexonsmith.
lenykholodov set the repository for this revision to rL LLVM.
lenykholodov added a subscriber: llvm-commits.
dexonsmith edited edge metadata.Dec 5 2015, 7:31 PM
dexonsmith added a subscriber: dexonsmith.

(Sorry for the delay; I'm still working through mail from Thanksgiving.)

+Rafael, since we worked on this change together, and I don't know much about ELF.

I do think this is a bug in the linker. It should strip symbols that
don't have a name in the same way it strips .L in mergeable sections.

Even if we want to create temp names, we can do that as a very late
pass in the elf writer.

I will try to make sure lld does the right thing and open bugs on bfd
ld and gold.

Thanks,
Rafael

OK, things were not that simple :-(

I fixed lld to drop unnamed symbols in cases it drops .L symbols (r255357).

The testcase you included finds another problem is llvm: the output
produced when going directly to a .o is different from what we get
when using a .s.

I reported pr25811 to track it. Unfortunately this area has bigger
problems that should probably be fixed first: pr18716.

Cheers,
Rafael

dexonsmith resigned from this revision.Oct 6 2020, 3:44 PM