[PATCH] D36874: [ELF] - Mention "-z notext" and -fPIC in some error messages

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 00:07:43 PDT 2017


grimar added inline comments.


================
Comment at: test/ELF/dynamic-reloc-in-ro.s:5-10
+// CHECK:      can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
+// CHECK-NEXT: >>> defined in {{.*}}.o
+// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x0)
+// CHECK-NEXT: >>> Usually this error happens when -fPIC flag is missing during compilation.
+// CHECK-NEXT: >>> Unintentional use of such relocations is undesirable, and not
+// CHECK-NEXT: >>> permited by default, consider using -z notext.
----------------
ruiu wrote:
> This error message style is not desirable, as two list elements ("defined in ..." and "referenced by ..." and the description text "Usually ..." are in the same list. That is just like this
> 
>   Found an error
>    - at file foo.c
>    - on line 100
>    - Usually this error happens when you made a mistake blah blah
> 
> and I believe you can see why this is wrong.
> 
> I also wonder if you really want to mention `-z notext`. We want to recommend or endorse the option because we want to avoid text relocations in general. In most cases, you just need to compile object files with -fPIC, so I believe you want to mention only that.
> 
> Overall, I'd change the message to "can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC to fix this error".
>I also wonder if you really want to mention -z notext. We want to recommend or endorse the option because we want to avoid text relocations >in general. In most cases, you just need to compile object files with -fPIC, so I believe you want to mention only that.

Reason behind mentioning -z notext is that it is by default in GNU linkers and LLD has -z text as default behavior.
It may we worth to mention as it not obvious and I expect users generally not know about this difference and
wondering why ld.bfd links fine but LLD errors out.


https://reviews.llvm.org/D36874





More information about the llvm-commits mailing list