Hi Sam,

   ''scons build/x86/out/m5 --verbose'' shows
   ```

   g++ -o build/x86/out/m5 -no-pie -static build/x86/call_type/inst.o 
build/x86/call_type/addr.o build/x86/args.o ...

   ```

   So I guess in your case either

   ```

   gcc -o test test.c -I./include -I./util/m5/src -L./util/m5/build/x86/out/ 
-lm5 -static

   ```

   or

   ```

   gcc -o test test.c -I./include -I./util/m5/src -L./util/m5/build/x86/out/ 
-lm5 -no-pie

   ```

   should work. The first method generates a static binary, and the second a 
dynamic one.

   PS. If you do "ar -x libm5.a" and then "readelf --relocs m5op_addr.o" you 
will see there is no PLT info for symbol m5_mem, which gives you the linker error.

   Hope this helps.

Best regards

Yuan


On 2024-09-11 00:24, Thomas, Samuel via gem5-users wrote:
Hi all,

I'm trying to model the SPEC HPC benchmark suite in gem5 with an x86 ISA using KVM. As a 
result, I am trying to link the "_addr" version of the m5ops against the 
binaries in order to model the region of interest. Unfortunately, I get the following 
error when trying to build the sample hello world example:

File contents (test.c): ```
#include <gem5/m5ops.h>
#include <m5_mmap.h>

int main(void) {
m5op_addr = 0xffff0000;
map_m5_mem();
m5_exit_addr(0);
return 0;
}
```

Error output: ```
$ gcc -o test test.c -I/gem5-include/ -I/m5-include/ -L/m5-out -lm5

/usr/bin/ld: /m5-out/libm5.a(m5op_addr.o): relocation R_X86_64_32S against 
symbol `m5_mem' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
```

The included headers from $(GEM5_DIR)/include are in the /gem5-include directory, the 
m5 utility headers (required to include <m5_mmap.h>) are in /m5-include, and 
the libraries and binaries are in /m5-out.

I added -fPIC to the CCFLAGS and CXXFLAGS of the SConscript in util/m5, but 
this didn't change the error post compilation. I also tried adding -fno-pie and 
get the error on compilation of the m5 binary instead:

```
LINK build/x86/test/bin/call_type/addr
/usr/bin/ld: build/x86/call_type/addr.test.to<http://addr.test.to>: relocation 
R_X86_64_32 against symbol `interceptEnv' can not be used when making a PIE object; 
recompile with -fPIE
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
scons: *** [build/x86/test/bin/call_type/addr] Error 1'')
```

The error happens if I try to build natively on my Ubuntu 20.04 host pointing 
to the files where they naturally are built in the base gem5 directory.

Any advice would be appreciated for where I may be going wrong on this! Thank 
you in advance for your help!

Best,
Sam


VARNING: Klicka inte på länkar och öppna inte bilagor om du inte känner igen 
avsändaren och vet att innehållet är säkert.
CAUTION: Do not click on links or open attachments unless you recognise the 
sender and know the content is safe.




_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org<mailto:gem5-users@gem5.org>
To unsubscribe send an email to 
gem5-users-le...@gem5.org<mailto:gem5-users-le...@gem5.org>









När du har kontakt med oss på Uppsala universitet med e-post så innebär det att 
vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du 
läsa här: http://www.uu.se/om-uu/dataskydd-personuppgifter/

E-mailing Uppsala University means that we will process your personal data. For 
more information on how this is performed, please read here: 
http://www.uu.se/en/about-uu/data-protection-policy
_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org

Reply via email to