Skip to content

Commit

Permalink
Report an error if a non-PIC object file is given for an PIC output
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Jul 31, 2023
1 parent 9fe3d75 commit e06d886
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions elf/input-files.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,11 @@ void ObjectFile<E>::scan_relocations(Context<E> &ctx) {
for (ElfRel<E> &rel : cie.get_rels()) {
Symbol<E> &sym = *this->symbols[rel.r_sym];

if (ctx.arg.pic && rel.r_type == E::R_ABS)
Error(ctx) << *this << ": relocation " << rel << " in .eh_frame can not"
<< " be used when making a position-independent output;"
<< " recompile with -fPIE or -fPIC";

if (sym.is_imported) {
if (sym.get_type() != STT_FUNC)
Fatal(ctx) << *this << ": " << sym
Expand Down

0 comments on commit e06d886

Please sign in to comment.