[PATCH] D28612: [ELF] - Added support for --emit-relocs.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 14:21:16 PST 2017
George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> if (B.isSection())
> - return Config->Relocatable;
> + return Config->Relocatable || Config->EmitRelocs;
You probably want a predicate for "Config->Relocatable ||
Config->EmitRelocs" as it is used multiple times.
> Index: ELF/LinkerScript.cpp
> ===================================================================
> --- ELF/LinkerScript.cpp
> +++ ELF/LinkerScript.cpp
> @@ -262,6 +262,21 @@
> for (InputSectionBase<ELFT> *S : V) {
> S->Live = false;
> reportDiscarded(S);
> +
> + if (!Config->EmitRelocs)
> + continue;
> +
> + // If we discard a section, we also should discard a relocation section
> + // connected, if any exist when --emit-relocs is specified.
> + ArrayRef<InputSectionBase<ELFT> *> Sections = S->getFile()->getSections();
> + for (InputSectionBase<ELFT> *IS : Sections) {
> + if (!IS || !IS->Live || (IS->Type != SHT_REL && IS->Type != SHT_RELA))
> + continue;
> + if (cast<InputSection<ELFT>>(IS)->getRelocatedSection() != S)
> + continue;
> + IS->Live = false;
> + reportDiscarded(IS);
> + }
You can get the same problem with --gc-sections, so you should handle it
in a more generic way as Rui pointed out.
Cheers,
Rafael
More information about the llvm-commits
mailing list