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

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 22 11:49:37 PDT 2017


ruiu 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.
----------------
grimar wrote:
> 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.
But how many moderm programs need text relocations? Printing out a hint for a rare error cause is more confusing than helpful. Even if you want to print out that hint, you still don't want to write it in a such way that you are not recommending the `-z notext` flag.


https://reviews.llvm.org/D36874





More information about the llvm-commits mailing list