[PATCH] D61767: [llvm-elfabi] Emit ELF header and string table section

Haowei Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 14:16:54 PST 2020


haowei added inline comments.


================
Comment at: llvm/lib/InterfaceStub/ELFObjHandler.cpp:561
+    Stream << FileReadError;
+    Stream << " when trying to open `" << FilePath << "` for writing";
+    consumeError(std::move(FileReadError));
----------------
grimar wrote:
> haowei wrote:
> > grimar wrote:
> > > You don't have a test for this I think.
> > Emmm, I tried locally on a linux machine and it seems to be difficult to put it in test case.
> > I have to create a file with same filename, change ownership and the permission so elfabi cannot modify it. And run llvm-elfabi to write output to this file. Is there any good way to trigger error from FileOutputBuffer?
> > 
> Perhaps I am missing something (I am not sure what the problem is).
> We have a few tests in LLVM (e.g see LLD tests, like lld\test\COFF\thinlto-emit-imports.ll) that
> do something very close to what you describe I think: they create a file, change permission and run tool on it:
> 
> ```
> ; RUN: rm -f %t3.obj.imports
> ; RUN: touch %t3.obj.imports
> ; RUN: chmod 400 %t3.obj.imports
> ; RUN: not lld-link -entry:main -thinlto-index-only \
> ; RUN:     -thinlto-emit-imports-files %t1.obj %t2.obj %t3.obj \
> ; RUN:     -out:%t4.exe 2>&1 | FileCheck %s --check-prefix=ERR
> ; ERR: cannot open {{.*}}3.obj.imports: {{P|p}}ermission denied
> ```
> 
> Can you do something like that?
I added "fail-file-write.test".
I thought it is discouraged to use rm, chmod commands since they are not cross-platforms.

Do I have to add anything to prevent this test from running on Windows? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61767/new/

https://reviews.llvm.org/D61767



More information about the llvm-commits mailing list