[PATCH] D15028: [ELF] Enable temporary labels symbol names

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 11 11:17:14 PST 2015


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

On 11 December 2015 at 10:46, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> 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
>
>
> On 26 November 2015 at 12:58, Leny Kholodov via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>> lenykholodov created this revision.
>> lenykholodov added a reviewer: dexonsmith.
>> lenykholodov added a subscriber: llvm-commits.
>> lenykholodov set the repository for this revision to rL LLVM.
>>
>> 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.
>>
>> Repository:
>>   rL LLVM
>>
>> http://reviews.llvm.org/D15028
>>
>> Files:
>>   lib/CodeGen/LLVMTargetMachine.cpp
>>   test/CodeGen/ARM/elf-debug-label-name.ll
>>
>> Index: test/CodeGen/ARM/elf-debug-label-name.ll
>> ===================================================================
>> --- test/CodeGen/ARM/elf-debug-label-name.ll
>> +++ test/CodeGen/ARM/elf-debug-label-name.ll
>> @@ -0,0 +1,37 @@
>> +; RUN: llc < %s -mtriple=armv7l-linux-eabihf -filetype=obj -o %s.o && llvm-objdump -t %s.o | FileCheck %s --check-prefix=CHECK
>> +; CHECK: .debug_str    00000000 .Linfo_string0
>> +; Function Attrs: nounwind
>> +define arm_aapcs_vfpcc i32 @_Z1xi(i32 %a) #0 !dbg !4 {
>> +entry:
>> +  %a.addr = alloca i32, align 4
>> +  store i32 %a, i32* %a.addr, align 4
>> +  call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !13, metadata !14), !dbg !15
>> +  %0 = load i32, i32* %a.addr, align 4, !dbg !16
>> +  ret i32 %0, !dbg !17
>> +}
>> +
>> +; Function Attrs: nounwind readnone
>> +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
>> +
>> +!llvm.dbg.cu = !{!0}
>> +!llvm.module.flags = !{!8, !9, !10, !11}
>> +!llvm.ident = !{!12}
>> +
>> +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
>> +!1 = !DIFile(filename: "file", directory: "dir")
>> +!2 = !{}
>> +!3 = !{!4}
>> +!4 = distinct !DISubprogram(name: "x", linkageName: "_Z1xi", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
>> +!5 = !DISubroutineType(types: !6)
>> +!6 = !{!7, !7}
>> +!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
>> +!8 = !{i32 2, !"Dwarf Version", i32 4}
>> +!9 = !{i32 2, !"Debug Info Version", i32 3}
>> +!10 = !{i32 1, !"wchar_size", i32 4}
>> +!11 = !{i32 1, !"min_enum_size", i32 4}
>> +!12 = !{!"clang"}
>> +!13 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 1, type: !7)
>> +!14 = !DIExpression()
>> +!15 = !DILocation(line: 1, column: 11, scope: !4)
>> +!16 = !DILocation(line: 3, column: 10, scope: !4)
>> +!17 = !DILocation(line: 3, column: 3, scope: !4)
>> Index: lib/CodeGen/LLVMTargetMachine.cpp
>> ===================================================================
>> --- lib/CodeGen/LLVMTargetMachine.cpp
>> +++ lib/CodeGen/LLVMTargetMachine.cpp
>> @@ -196,8 +196,11 @@
>>      if (!MCE || !MAB)
>>        return true;
>>
>> -    // Don't waste memory on names of temp labels.
>> -    Context->setUseNamesOnTempLabels(false);
>> +    if (getObjFileLowering()->getObjectFileType() ==
>> +        MCObjectFileInfo::Environment::IsELF) {
>> +      // Don't waste memory on names of temp labels.
>> +      Context->setUseNamesOnTempLabels(false);
>> +    }
>>
>>      Triple T(getTargetTriple().str());
>>      AsmStreamer.reset(getTarget().createMCObjectStreamer(
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>


More information about the llvm-commits mailing list