# how to set pie_base to randomize



## Raffeale (Apr 18, 2021)

I want to let the pie_base address to be randomize, how to do it?


----------



## Alain De Vos (Apr 18, 2021)

sysctl.conf

```
#adres map randomization
kern.elf32.aslr.pie_enable=1
kern.elf32.aslr.enable=1
kern.elf64.aslr.pie_enable=1
kern.elf64.aslr.enable=1
```

I don't know the status of it related to zfs or firefox.


----------



## Raffeale (Apr 19, 2021)

This is ASLR address, I mean that I want to change pie base address to be randomize.


----------



## Alain De Vos (Apr 19, 2021)

What i found was : gcc -fpie -pie. (use correct case)


----------



## Raffeale (Apr 19, 2021)

Alain De Vos said:


> What i found was : gcc -fpie -pie. (use correct case)


This is compile parameters, it can't change pie base address, I have to change it with sysctl kern.elf64.pie_base to change it. It is not convenient.


----------



## Alain De Vos (Apr 19, 2021)

Lets be reasonable.
There is an address.
Someone has to decide.
Or the compiler, so you give a flag.
Or the O.S. , and there is not much choise for telling the O.S. what to do.


----------



## Raffeale (Apr 19, 2021)

I think the pie base is program load address, it's a base address, that mean the program could be loaded by this address, if the program is compiled with pie, that means the programs could be loaded any address I think. Is it right? If this is right, I want to the pie base address changed automatically every time when a program is loading. that's I want it.


----------



## SirDice (Apr 19, 2021)

Raffeale said:


> I want to the pie base address changed automatically every time when a program is loading.


What do you think ASLR does?





__





						AddressSpaceLayoutRandomization - FreeBSD Wiki
					





					wiki.freebsd.org


----------



## Raffeale (Apr 19, 2021)

yes ,i know that make program load random address .
does the alsr is base on  pie_base address to load a program?
i have just checked the libc.so is random address in freebsd 13.


----------



## Alain De Vos (Apr 19, 2021)

Interesting ntpd & firefox have problems with aslr. I wonder why.


----------

