[PATCH] D15028: [ELF] Enable temporary labels symbol names
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 11 07:46:55 PST 2015
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