SWDEV-490256 - Fix uri_decode logic to handle Memory URI.

Uri decoder logic currently silently ignores processing of memory uri.
This patch enables the existing logic to handle the processing of offset
and size related to loaded code-object having memory URI.

Change-Id: If03579cefb11d91f667410464dc89404df9270a3


[ROCm/clr commit: 11cd37ce0b]
Dieser Commit ist enthalten in:
Amit Pandey verfasst und Amit Pandey committed 2024-12-25 11:07:16 -05:00
1 Ursprung f20f399915
Commit 81a25f9614
2 Dateien geändert
+27 -28

Keine Dateien entsprechen Ihrer Suche

+3 -3
Datei anzeigen
@@ -96,9 +96,9 @@ void handleSanitizerService(Payload* packt_payload, uint64_t activemask,
int64_t loadAddrAdjust = 0;
auto uri_fd = amd::Os::FDescInit();
if (uri_locator) {
device::UriLocator::UriInfo fileuri_info = uri_locator->lookUpUri(callstack[0]);
std::tie(offset, size) = uri_locator->decodeUriAndGetFd(fileuri_info, &uri_fd);
loadAddrAdjust = fileuri_info.loadAddressDiff;
device::UriLocator::UriInfo uri_info = uri_locator->lookUpUri(callstack[0]);
std::tie(offset, size) = uri_locator->decodeUriAndGetFd(uri_info, &uri_fd);
loadAddrAdjust = uri_info.loadAddressDiff;
}
#if defined(__linux__)
+24 -25
Datei anzeigen
@@ -106,7 +106,7 @@ std::pair<uint64_t, uint64_t> UriLocator::decodeUriAndGetFd(UriInfo& uri,
if (uri.uriPath.size() == 0)
return {0,0};
auto pos = uri.uriPath.find("//");
if (pos == std::string::npos || uri.uriPath.substr(0, pos) != "file:") {
if (pos == std::string::npos) {
uri.uriPath="";
return {0,0};
}
@@ -126,32 +126,31 @@ std::pair<uint64_t, uint64_t> UriLocator::decodeUriAndGetFd(UriInfo& uri,
else {
rspos = uri.uriPath.size()-1;
}
pos += 2;
//decode filepath
for (auto i=pos; i<= rspos;) {
cur = uri.uriPath[i];
if (isalnum(cur) || cur == '/' || cur == '-' ||
cur == '_' || cur == '.' || cur == '~') {
ss << cur;
i++;
}
else {
//characters prefix with '%' char
char tbits = uri.uriPath[i+1], lbits = uri.uriPath[i+2];
uint8_t t = (tbits < 58) ? ( tbits - 48) : ((tbits - 65) + 10);
uint8_t l = (lbits < 58) ? ( lbits - 48) : ((lbits - 65) + 10);
ss << (char)(((0b00000000 | t)<<4) | l);
i += 3;
if (uri.uriPath.substr(0, pos) == "file:") {
pos += 2;
// decode filepath
for (auto i = pos; i <= rspos;) {
cur = uri.uriPath[i];
if (isalnum(cur) || cur == '/' || cur == '-' || cur == '_' || cur == '.' || cur == '~') {
ss << cur;
i++;
} else {
// characters prefix with '%' char
char tbits = uri.uriPath[i + 1], lbits = uri.uriPath[i + 2];
uint8_t t = (tbits < 58) ? (tbits - 48) : ((tbits - 65) + 10);
uint8_t l = (lbits < 58) ? (lbits - 48) : ((lbits - 65) + 10);
ss << (char)(((0b00000000 | t) << 4) | l);
i += 3;
}
}
uri.uriPath = ss.str();
size_t fd_size;
(void)amd::Os::GetFileHandle(uri.uriPath.c_str(), uri_fd, &fd_size);
// As per URI locator syntax, range_specifier is optional
// if range_specifier is absent return total size of the file
// and set offset to begin at 0.
if (size == 0) size = fd_size;
}
uri.uriPath = ss.str();
size_t fd_size;
(void) amd::Os::GetFileHandle(uri.uriPath.c_str(), uri_fd, &fd_size);
// As per URI locator syntax, range_specifier is optional
// if range_specifier is absent return total size of the file
// and set offset to begin at 0.
if (size == 0)
size = fd_size;
return {offset, size};
}