Patching AIX binary - aix

I am attached to a running proces using dbx on AIX. There is a bug in the program, the offset in the opcode below is 0x9b8, but should be 0xbe8:
(dbx) listi 0x100001b14
0x100001b14 (..........+0x34) e88109b8 ld r4,0x9b8(r1)
I am able to fix that using the command below:
(dbx) assign 0x100001b14 = 0xe8810be8
but that affects only the running process and its memory. How can I change the on disk binary? I am not able to locate the pattern e88109b8 in the binary file,
otherwise I would use e.g. dd utility to patch it.
Best regards,
Pavel Filipensky

Related

FlexSPI erase and write issue on NXP 2160A-TCD platform

We encounter FLEXSPI erase and write issue. We use the following commands to test FLEXSPI read, write, and erase.
mtd_debug erase /dev/mtd2 0x0000000 0x10000
dd if=/dev/zero of=data.hex count=1 bs=65536
mtd_debug write /dev/mtd2 0x0000000 0x10000 data.hex
mtd_debug read /dev/mtd2 0x0000000 0x10000 dump
The contents of data.hex and dump files should be same. But unfortunately the contents of these two files are not identical.
spi-nxp-fspi.c is FLEXSPI driver source file.
I have fixed this issue by disabling erasing and writing protection from NOR flash register.

How do i set up instruction & data memory address when using "riscv32-unknown-elf-gcc"?

I designed RISCV32IM processor, and I used "riscv32-unknown-elf-gcc" to generate code for testing.
However, the PC(instruction memory address) value and data memory address of the generated code had arbitrary values. I used this command:
riscv32-unknown-elf-gcc -march=rv32im -mabi=ilp32 -nostartfiles test.c
Can I know if I can set the instruction and data memory address I want?
Thanks.
Thank you for answer.
I designed only HW, and this is my first time using the SW tool chain.
Even if my question is rudimentary, please understand.
The figure is the result of the "-v" option.
enter image description here
I can't modify the script file because I use riscv tool chain in DOCKER environment.
So, I tried to copy the script file (elf32lriscv.x), modify it.
I modified it to 0x10000 ==> 0x00000.
The file name of the copied script is "test5.x".
And it was executed as follows.
What am I doing wrong?
enter image description here
The riscv compiler is using the default linker script to place text and date section... .
If you add -v option to your command line riscv32-unknown-elf-gcc -v -march=rv32im -mabi=ilp32 -nostartfiles test.c, you will see the linker script used by collect 2 ( normally it will be -melf32lriscv . you can find the linker script in ${path_to_toolchain}/riscv32-unknown-elf/lib/ldscripts/ (the default one is .x).
You can also use riscv32-unknown-elf-ld --verbose like explained by #Frant. However , you need to be careful if the toolchain was compiled with enable multilib and you compile for rv64 but the default is rv32 or vice versa. It is not the case probably, but to be sure you can specify the arch with -A elf32riscv for an rv32.
To Set the addresses you can create your own linker script or copy and modify the default one. You can only modify the executable start like explained by #Frant or make more modification and place whatever you want where you want.
Once your own linker script ready you can pass it to the linker with -Wl,-T,${own_linker_script }. you command will be riscv32-unknown-elf-gcc -march=rv32im -mabi=ilp32 -nostartfiles test.c -Wl,-T,${own_linker_script }

Error 94,20 on open statement on a 23 character file namefile

I'm Importing csv files provided by a third party vendor into a COBOL application. The file names are 23 characters long in .csv format. These files as delivered read successfully and correctly into Excel, Word and Vi.
When I open any of these files using the provided file names I get a COBOL error 94,20 - file not found. This occurs in both SCO OpenServer 5.0.7 (Unix) and Windows 7 runtime environments.
However if I shorten the file name (arbitrarily to 4 characters) I can open, read and close the file with no problems.
Is there a COBOL limit on the number of characters allowed in a sequential input file name? What else might cause such an open failure?
I'm running Micro-focus/ACUCOBOL-GT V7.00 compiler and ACUCOBOL-GT runtime version 5.2.1.
Older versions of SCO Unix (predecessor of SCO OpenServer) had a 14-character filename limit. If your files are named 'something.csv' then the 'something' part would have been limited to 10 chars.
This limit should not apply on OpenServer 5.0.7. However, if the COBOL you're using was compiled on a much older release, or if it's newer but voluntarily restricts its filename support in an attempt to maintain backwards compatibility, that might be the problem. You could probe this by testing it against 13, 14, 15-char filenames -- well, in general, probe different lengths to learn the actual limit.
Your 5.0.7 system should have the system call tracer command truss(C), and may also have trace(CP) (if you have the C development system installed). Running truss how-you-start-a-cobol-program longfilename.csv may produce useful output, e.g. the actual syscall and system error number which result in the error you see. The OSR5 versions of both truss and trace are moderately flaky (in different ways), so try both. Read their man pages for stuff like the "-o" flag to write output to a file.

How to use csvSeparator with jpexport (jprofiler)?

I am using jprofiler to make some tests about the memory usage of my application. I would like to include them in my build process. All the steps should work in command like.
On step exports csv file from jps file with a command like:
~/jprofiler7/bin/jpexport q1.jps "TelemetryHeap" -format=csv q1_telemetry_heap.csv
On my local machine (widows), it is working. On my server (linux) the csv file is not well formatted:
"Time [s]","Committed size","Free size","Used size"
0.0,30,784,000,19,558,000,11,226,000
1.0,30,976,000,18,376,000,12,600,000
2.0,30,976,000,16,186,000,14,790,000
3.0,30,976,000,16,018,000,14,958,000
4.01,30,976,000,14,576,000,16,400,000
They is no way to distinguish the comma of csv format and the one of the numbering format.
According to the documentation, I need to change the value of -Djprofiler.csvSeparator in the file bin/export.vmoptions.
But I fail. I also try to change this value in jpexport.vmoptions and in jprofiler.vmoptions.
What should I do?
Thanks for your help
This bug was fixed in JProfiler 8.0.2.
Adding
-Djprofiler.csvSeparator=;
on a new line in bin/jpexport.vmoptions should work in JProfiler 7, though.

How to edit a device driver file(.sys)

How I can edit a device driver file (.sys) and I want to update the Report Descriptor file. I want to transpose the X and Y value of USB HID device driver. Please help me to transpose the X & Y value in an HID device.
use a binary editor, or if you are really careful, vi. note that whatever you do, leave strings exactly the same length or you will almost definitely crash your operating system.
assuming you are using Windows, good old debug.exe will work fine as a binary editor. the interface is a bit obscure though.
C:\Users\jc>echo bleah > test.sys
C:\Users\jc>debug test.sys
-e100
17DD:0100 62.31 6C.32 65.33 61.34 68.35
-w
Writing 00008 bytes
-q
C:\Users\jc>type test.sys
12345
on the line following -e100, I was typing the new values and hitting the spacebar; when done I hit <enter>.
You can use any static disassembler for Win32/Win64. This way you will better see the code instructions, function names, and be able to find your target easily (otherwise reading machine code directly it's for priviledged minds).
One example can be "PEBrowse Professional" (free) but there are many other out there. The one I cited is verified to open 64-sys of Win10.