[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [microblaze-uclinux] output file permissions on microblaze-uclinux-gcc



Thanks for the quick response John.  I patched the scripts so my microblaze-uclinux-gcc matches my native gcc.
It looks like gcc pays attention to umask:
 
[jim@ares tmp]$ umask 7
[jim@ares tmp]$ gcc foo.c
[jim@ares tmp]$ dir a.out
-rwxrwx--- 1 jim ee 4611 Mar 20 10:07 a.out
[jim@ares tmp]$ umask 2
[jim@ares tmp]$ gcc foo.c
[jim@ares tmp]$ dir a.out
-rwxrwxr-x 1 jim ee 4611 Mar 20 10:07 a.out
[jim@ares tmp]$ umask 22
[jim@ares tmp]$ gcc foo.c
[jim@ares tmp]$ dir a.out
-rwxr-xr-x 1 jim ee 4611 Mar 20 10:10 a.out
So probably the correct thing is to modify the scripts to pay attention to umask.
 


From: owner-microblaze-uclinux@xxxxxxxxxxxxxx [mailto:owner-microblaze-uclinux@xxxxxxxxxxxxxx] On Behalf Of John Williams
Sent: Thursday, March 19, 2009 7:26 PM
To: microblaze-uclinux@xxxxxxxxxxxxxx; uclinux-dev@xxxxxxxxxxx
Subject: Re: [microblaze-uclinux] output file permissions on microblaze-uclinux-gcc

Hi Jim, (cross-posted to uclinux-dev for wider audience)

On Fri, Mar 20, 2009 at 4:16 AM, Jim Van Vorst <jvanvorst@xxxxxxxxx> wrote:
 
When generating an executable with microblaze-uclinux-gcc, it sets the permissions of the output file as 740 (user rwx, group r) whereas my native gcc sets it to 770, which is what I want.  Anyone know how to change this?

Looks like the linker (or more likely, the elf2flt post link processing) is the culprit:

$ gcc -c -o hello-host.o hello.c
$ gcc -o hello-host hello.c

$ ls -al hello-host*
-rwxrwxr-x 1 jwilliams jwilliams 4721 Mar 20 12:08 hello-host
-rw-rw-r-- 1 jwilliams jwilliams  864 Mar 20 12:08 hello-host.o

So my native GCC (gcc 4.1.2 on CentOS 5) creates objfile with perms 664, executable with 775

Same, but with microblaze-uclinux-gcc:

$ microblaze-uclinux-gcc -c -o hello-target.o hello.c
$ microblaze-uclinux-gcc  -o hello-target hello.c
$ ls -al hello-target*
-rwxr--r-- 1 jwilliams jwilliams 29764 Mar 20 12:12 hello-target
-rwxrwxr-x 1 jwilliams jwilliams 62046 Mar 20 12:12 hello-target.gdb
-rw-rw-r-- 1 jwilliams jwilliams   696 Mar 20 12:10 hello-target.o

So the .o has the same perms 664, but the executable is 744 (which is a bit wierd)

What's your umask?  Mine is

$ umask
0002

A quick fix is to hack the microblaze-uclinux-ld and ld scripts to chmod as required.  Note ld is a script in uclinux toolchain that then calls real linker renamed as ld.real

Index: tools/linux-i386/microblaze-uclinux-tools/microblaze-uclinux/bin/ld
===================================================================
--- tools/linux-i386/microblaze-uclinux-tools/microblaze-uclinux/bin/ld        (revision 5150)
+++ tools/linux-i386/microblaze-uclinux-tools/microblaze-uclinux/bin/ld        (working copy)
@@ -161,6 +161,7 @@
                fi
                rm -f "$OFILE.elf"  # not needed for any reason
                rm -f "$NEWLDSCRIPT"
+               chmod 775 "$OFILE"
                exit 0
        fi
 
You also want to apply the same change to microblaze-linux-ld in tools/linux-i386/microblaze-uclinux-tools/bin/microblaze-uclinux-ld

Can you find any info on default perms on gcc/ld outputs?  Clearly the flat binaries should follow the same rules.

Regards,

John

--
John Williams, PhD, B.Eng, B.IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663