[PATCH] D65140: [yaml2obj] - Allow custom fields for the SHT_UNDEF sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 02:22:25 PDT 2019


grimar added a comment.

In D65140#1600579 <https://reviews.llvm.org/D65140#1600579>, @grimar wrote:

> In D65140#1600570 <https://reviews.llvm.org/D65140#1600570>, @MaskRay wrote:
>
> > If you just want to check the size of a file, just use `ls -l`. As POSIX says:
> >
> > > If the -l option is specified, the following information shall be written for files other than character special and block special files:
> >
> >
> >
> >   "%s %u %s %s %u %s %s\n", <file mode>, <number of links>,
> >       <owner name>, <group name>, <size>, <date and time>,
> >       <pathname>
> >
> >
> > You can just use `ls -l %t | cut -d ' ' -f 5` to retrieve the size field.
>
>
> I'll try this, thanks!


It doesn't work as is on windows :) The reason seems is an additional space printed after permissions.
I.e. what is 5th field on linux, it is 6th field on windows because of that:

> D:\Work2\llvm>ls -l D:\Work2\llvm\llvm_build\test\tools\yaml2obj\Output\elf-custom-null-section.yaml.tmp4
>  -rw-rw-rw-  1 anon 0 377 2019-07-25 11:50 D:\Work2\llvm\llvm_build\test\tools\yaml2obj\Output\elf-custom-null-section.yaml.tmp4

The output above ^^^ has double space after "rw-rw-rw-"

> D:\Work2\llvm>ls -l D:\Work2\llvm\llvm_build\test\tools\yaml2obj\Output\elf-custom-null-section.yaml.tmp4 | cut -d " " -f 1
> -rw-rw-rw-
> 
> D:\Work2\llvm>ls -l D:\Work2\llvm\llvm_build\test\tools\yaml2obj\Output\elf-custom-null-section.yaml.tmp4 | cut -d " " -f 2
> 
> D:\Work2\llvm>ls -l D:\Work2\llvm\llvm_build\test\tools\yaml2obj\Output\elf-custom-null-section.yaml.tmp4 | cut -d " " -f 3
> 1
> 
> D:\Work2\llvm>ls -l D:\Work2\llvm\llvm_build\test\tools\yaml2obj\Output\elf-custom-null-section.yaml.tmp4 | cut -d " " -f 4
> anon
> 
> D:\Work2\llvm>ls -l D:\Work2\llvm\llvm_build\test\tools\yaml2obj\Output\elf-custom-null-section.yaml.tmp4 | cut -d " " -f 5
> 0
> 
> D:\Work2\llvm>ls -l D:\Work2\llvm\llvm_build\test\tools\yaml2obj\Output\elf-custom-null-section.yaml.tmp4 | cut -d " " -f 6
> 377

I had to use `ls -l %t3 | tr -s ' ' | cut -d ' ' -f 5` finally.


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

https://reviews.llvm.org/D65140





More information about the llvm-commits mailing list