[lld] r351852 - FileOutputBuffer: Handle "-" as stdout.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 22 10:44:05 PST 2019


Author: ruiu
Date: Tue Jan 22 10:44:04 2019
New Revision: 351852

URL: http://llvm.org/viewvc/llvm-project?rev=351852&view=rev
Log:
FileOutputBuffer: Handle "-" as stdout.

I was honestly a bit surprised that we didn't do this before. This
patch is to handle "-" as the stdout so that if you pass `-o -` to
lld, for example, it writes an output to stdout instead of file `-`.

I thought that we might want to handle this at a higher level than
FileOutputBuffer, because if we land this patch, we can no longer
create a file whose name is `-` (there's a workaround though; you can
pass `./-` instead of `-`). However, because raw_fd_ostream already
handles `-` as a special file name, I think it's okay and actually
consistent to handle `-` as a special name in FileOutputBuffer.

Differential Revision: https://reviews.llvm.org/D56940

Added:
    lld/trunk/test/ELF/stdout.s

Added: lld/trunk/test/ELF/stdout.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/stdout.s?rev=351852&view=auto
==============================================================================
--- lld/trunk/test/ELF/stdout.s (added)
+++ lld/trunk/test/ELF/stdout.s Tue Jan 22 10:44:04 2019
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -o - > %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+# CHECK: 0000000000201000 _start:
+# CHECK: 201000: 90 nop
+
+.globl _start
+_start:
+  nop




More information about the llvm-commits mailing list